From bfbc4ffd587943d2dd810700c031a690196eec2b Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 16 Jul 2024 11:57:37 -0500 Subject: [PATCH] style application --- .../java/ucar/nc2/dataset/VariableDS.java | 10 +++---- .../main/java/ucar/nc2/filter/Classifier.java | 26 +++++++++---------- .../ucar/nc2/filter/EnhancementProvider.java | 17 ++++++------ .../main/java/ucar/nc2/filter/Normalizer.java | 23 +++++++++------- .../java/ucar/nc2/filter/ScaleOffset.java | 10 +++---- .../java/ucar/nc2/filter/Standardizer.java | 17 +++++++----- 6 files changed, 56 insertions(+), 47 deletions(-) diff --git a/cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java b/cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java index fce6664d0d..0091766593 100644 --- a/cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java +++ b/cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java @@ -32,7 +32,7 @@ * @author caron * @see NetcdfDataset */ -public class VariableDS extends Variable implements VariableEnhanced, EnhanceScaleMissingUnsigned{ +public class VariableDS extends Variable implements VariableEnhanced, EnhanceScaleMissingUnsigned { @@ -287,7 +287,7 @@ Array convert(Array data, Set enhancements) { toApply.add(scaleOffset); convertedType = scaleOffset.getScaledOffsetType(); } -/** this == variableDS */ + /** this == variableDS */ for (Enhance enhance : enhancements) { for (EnhancementProvider service : ServiceLoader.load(EnhancementProvider.class)) { if (service.appliesTo(enhance, this)) { @@ -939,15 +939,15 @@ private void createEnhancements() { } this.dataType = scaleOffset != null ? scaleOffset.getScaledOffsetType() : this.dataType; } -/** how oh how ??? */ + /** how oh how ??? */ for (Enhance enhance : this.enhanceMode) { for (EnhancementProvider service : ServiceLoader.load(EnhancementProvider.class)) { /** Stand and Norm require floatingpoint, buc classifier can do just numeric? */ - if (service.appliesTo(enhance,this.attributes())&& dataType.isFloatingPoint()) { + if (service.appliesTo(enhance, this.attributes()) && dataType.isFloatingPoint()) { service.Create(this); } - } } + } } diff --git a/cdm/core/src/main/java/ucar/nc2/filter/Classifier.java b/cdm/core/src/main/java/ucar/nc2/filter/Classifier.java index 76807e4768..0ad3a1ff81 100644 --- a/cdm/core/src/main/java/ucar/nc2/filter/Classifier.java +++ b/cdm/core/src/main/java/ucar/nc2/filter/Classifier.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.*; + public class Classifier implements Enhancement { @@ -147,8 +148,8 @@ public static int[] stringToIntArray(String str) { public static class Provider implements EnhancementProvider { @Override - public void Create(VariableDS var){ - var.classifier=Classifier.createFromVariable(var); + public void Create(VariableDS var) { + var.classifier = Classifier.createFromVariable(var); } @@ -157,26 +158,28 @@ public void Create(VariableDS var){ public String getName() { return name; } + @Override - public boolean canDo (Set enhancements){ + public boolean canDo(Set enhancements) { if (enhancements.contains(Enhance.ApplyClassifier)) { return true; } return false; } -// Attribute findAttribute(String attName); + // Attribute findAttribute(String attName); @Override - public boolean appliesTo(Enhance enhance, AttributeContainer attributes) { - return enhance == Enhance.ApplyClassifier && attributes.findAttribute(CDM.CLASSIFY)!= null; + public boolean appliesTo(Enhance enhance, AttributeContainer attributes) { + return enhance == Enhance.ApplyClassifier && attributes.findAttribute(CDM.CLASSIFY) != null; } + @Override - public boolean appliesTo(Enhance enhance,VariableDS var){ - return enhance == Enhance.ApplyClassifier && var.classifier!=null; + public boolean appliesTo(Enhance enhance, VariableDS var) { + return enhance == Enhance.ApplyClassifier && var.classifier != null; } - public Classifier returnObject( VariableDS var){ + public Classifier returnObject(VariableDS var) { return var.classifier; } @@ -186,9 +189,6 @@ public Classifier returnObject( VariableDS var){ - - } - - +} diff --git a/cdm/core/src/main/java/ucar/nc2/filter/EnhancementProvider.java b/cdm/core/src/main/java/ucar/nc2/filter/EnhancementProvider.java index 75cf074401..b2718d9c33 100644 --- a/cdm/core/src/main/java/ucar/nc2/filter/EnhancementProvider.java +++ b/cdm/core/src/main/java/ucar/nc2/filter/EnhancementProvider.java @@ -6,7 +6,7 @@ package ucar.nc2.filter; import java.util.Map; -//package ucar.nc2.dataset; +// package ucar.nc2.dataset; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; @@ -30,19 +30,20 @@ */ public interface EnhancementProvider { - String getName(); + String getName(); - boolean canDo (Set enhancements); + boolean canDo(Set enhancements); - boolean appliesTo(Enhance enhance, AttributeContainer attributes); + boolean appliesTo(Enhance enhance, AttributeContainer attributes); - boolean appliesTo(Enhance enhance, VariableDS var); + boolean appliesTo(Enhance enhance, VariableDS var); - void Create(VariableDS var); - Enhancement returnObject(VariableDS var); + void Create(VariableDS var); + Enhancement returnObject(VariableDS var); -// void applyEnhancement(Object instance); + + // void applyEnhancement(Object instance); } diff --git a/cdm/core/src/main/java/ucar/nc2/filter/Normalizer.java b/cdm/core/src/main/java/ucar/nc2/filter/Normalizer.java index 401e7f86e7..11a82e4974 100644 --- a/cdm/core/src/main/java/ucar/nc2/filter/Normalizer.java +++ b/cdm/core/src/main/java/ucar/nc2/filter/Normalizer.java @@ -20,6 +20,7 @@ public class Normalizer implements Enhancement { private final double minimum; private final double range; // maximum - minimum private static String name = "Normalizer"; + public static Normalizer createFromVariable(VariableDS var) { try { Array arr = var.read(); @@ -75,19 +76,22 @@ public double getMinimum() { public double getRange() { return range; } + public static class Provider implements EnhancementProvider { @Override - public void Create(VariableDS var){ - var.normalizer=Normalizer.createFromVariable(var); + public void Create(VariableDS var) { + var.normalizer = Normalizer.createFromVariable(var); } + @Override public String getName() { return name; } + @Override - public boolean canDo (Set enhancements){ + public boolean canDo(Set enhancements) { if (enhancements.contains(Enhance.ApplyNormalizer)) { return true; } @@ -96,20 +100,21 @@ public boolean canDo (Set enhancements){ @Override public boolean appliesTo(Enhance enhance, AttributeContainer attributes) { - return enhance == Enhance.ApplyNormalizer && attributes.findAttribute(CDM.NORMALIZE)!= null; + return enhance == Enhance.ApplyNormalizer && attributes.findAttribute(CDM.NORMALIZE) != null; } + @Override - public boolean appliesTo(Enhance enhance,VariableDS var){ - return enhance == Enhance.ApplyNormalizer && var.normalizer!= null; + public boolean appliesTo(Enhance enhance, VariableDS var) { + return enhance == Enhance.ApplyNormalizer && var.normalizer != null; } -@Override - public Normalizer returnObject( VariableDS var){ + + @Override + public Normalizer returnObject(VariableDS var) { return var.normalizer; } - } } diff --git a/cdm/core/src/main/java/ucar/nc2/filter/ScaleOffset.java b/cdm/core/src/main/java/ucar/nc2/filter/ScaleOffset.java index b2cccb98a5..a4a7cb1edd 100644 --- a/cdm/core/src/main/java/ucar/nc2/filter/ScaleOffset.java +++ b/cdm/core/src/main/java/ucar/nc2/filter/ScaleOffset.java @@ -274,7 +274,7 @@ private Number convertUnsigned(Number value, Signedness signedness) { } - public static class Provider implements FilterProvider{ + public static class Provider implements FilterProvider { @Override public String getName() { @@ -291,10 +291,10 @@ public Filter create(Map properties) { return new ScaleOffset(properties); } -// @Override -// public void doSomething(double val) { -// System.out.println("SCALEOFFSET ! "+val); -// } + // @Override + // public void doSomething(double val) { + // System.out.println("SCALEOFFSET ! "+val); + // } } diff --git a/cdm/core/src/main/java/ucar/nc2/filter/Standardizer.java b/cdm/core/src/main/java/ucar/nc2/filter/Standardizer.java index b01cda7181..a0a5f6c4da 100644 --- a/cdm/core/src/main/java/ucar/nc2/filter/Standardizer.java +++ b/cdm/core/src/main/java/ucar/nc2/filter/Standardizer.java @@ -82,16 +82,18 @@ public double getStdDev() { public static class Provider implements EnhancementProvider { @Override - public void Create(VariableDS var){ - var.standardizer=Standardizer.createFromVariable(var); + public void Create(VariableDS var) { + var.standardizer = Standardizer.createFromVariable(var); } + @Override public String getName() { return name; } + @Override - public boolean canDo (Set enhancements){ + public boolean canDo(Set enhancements) { if (enhancements.contains(Enhance.ApplyStandardizer)) { return true; } @@ -100,15 +102,16 @@ public boolean canDo (Set enhancements){ @Override public boolean appliesTo(Enhance enhance, AttributeContainer attributes) { - return enhance == Enhance.ApplyStandardizer && attributes.findAttribute(CDM.STANDARDIZE)!= null; + return enhance == Enhance.ApplyStandardizer && attributes.findAttribute(CDM.STANDARDIZE) != null; } + @Override - public boolean appliesTo(Enhance enhance,VariableDS var){ - return enhance == Enhance.ApplyStandardizer && var.standardizer!= null; + public boolean appliesTo(Enhance enhance, VariableDS var) { + return enhance == Enhance.ApplyStandardizer && var.standardizer != null; } @Override - public Standardizer returnObject( VariableDS var){ + public Standardizer returnObject(VariableDS var) { return var.standardizer; } }