I recently went through one of Netflix's open source
There I found the use of both the final class and the private constructor. I am fully aware that
But itβs just interesting to know why they are both used together. Although the methods are static, so we can use them without instantiating, but still want to know the design principle.
With this code you will have these functions
extends
singleton , IHMO helper/util API Netflix, , :
StaticFinalClassExample.methodYouWantToCall();
, , :
/** * This class consists exclusively of static methods that help verify the compliance of OP1A-conformant.... */
//to prevent instantiation private IMFConstraints() {}
, Item 4 Joshua Bloch Java (2- ):
Item 4
4:, . , , , .java.lang.Math java.util.Arrays., factory ( 1), , , java.util.Collections., final .: . . . API.. , - . , , , ( 17)., , , . , , , .
4:
, . , , , .
java.lang.Math
java.util.Arrays
java.util.Collections
final
: . . . API.
. , - . , , , ( 17).
, , , . , , , .
static "", , , , . , , .
static
2: , (, ). static factory, . :
public static IMFConstraints getInstance()
, . static, . :
public static void checkIMFCompliance(List<PartitionPack> partitionPacks)
:
// your cool client code here... IMFConstraints.checkIMFCompliance(myPartitionPacks); // more of your awesome code...
- .
Source: https://habr.com/ru/post/1652042/More articles:How to open a CSV file created by POST - javascriptspecify max size of json log file in docker - dockerWhy is it considered approved to mutate a shallow copy of my condition? - javascriptRandom 400 token_invalid errors with Laravel / jwt-auth and Angular / Satellizer app - angularjsfill in missing Oracle data - sqlORACLE SQL: fill in missing dates - sqlHow to enable Javascript to communicate with Python 2.7 Bottle through WebSockets? - python-2.7How to fill in missing dates and values ββin partitioned data? - dateHow to populate a calendar table in Oracle? - sqlRepeat the title on each page using css while printing. - htmlAll Articles