I suppose you mean methods instead of functions? You really have to imagine that the word staticdoes not exist in the Java world, there really are no cases when staticit actually does something good for you in the long run.
, API, , , , .
, , , , , . , , , , , , .
, , , myUtil.someGroup().someMethod(param1, param2);. , API: , , - Apache Wicket Settings , , .
, , , , , , .
public class ImageUtil {
public static BufferedImage adjustHue(float difference,
BufferedImage original) {
return adjusted;
}
public static BufferedImage adjustBrightness(float difference,
BufferedImage original) {
return adjusted;
}
public static BufferedImage adjustContrast(float difference,
BufferedImage original) {
return adjusted;
}
public static BufferedImage setHeight(int newHeight,
BufferedImage original) {
return adjusted;
}
public static BufferedImage setWidth(int newWidth,
BufferedImage original) {
return adjusted;
}
}
public interface IImageColorOperations {
BufferedImage adjustHue(float difference, BufferedImage original);
BufferedImage adjustBrightness(float difference, BufferedImage original;)
BufferedImage adjustContrast(float difference, BufferedImage original);
}
public interface IImageDimensionOperations {
BufferedImage setHeight(int newHeight, BufferedImage original);
BufferedImage setWidth(int newWidth, BufferedImage original);
}
, " "
public class ImageUtils {
private final IImageDimensionOperations dimension;
private final IImageColorOperations color;
public ImageUtils() {
this(new ImageDimensionOperations(),
new ImageColorOperations());
}
public ImageUtils(IImageDimensionOperations dimension,
IImageColorOperations color) {
this.dimension = dimension;
this.color = color;
}
}
, ! , , .
, :
public class ImageUtils implements IImageDimensionOperations,
IImageColorOperations {
private final IImageDimensionOperations dimension;
private final IImageColorOperations color;
public ImageUtils() {
this(new ImageDimensionOperations(),
new ImageColorOperations());
}
}
. , , , .
, ( finals !):
public class ImageUtils {
public final IImageDimensionOperations dimension;
public final IImageColorOperations color;
public ImageUtils() {
this(new ImageDimensionOperations(),
new ImageColorOperations());
}
public ImageUtils(IImageDimensionOperations dimension,
IImageColorOperations color) {
this.dimension = dimension;
this.color = color;
}
}
, ,
BufferedImage adjusted = imageUtils.color.adjustHue(3.2f, original);
- , - . , , - - Java, , , finals, ( ).