Enable checkstyle in yang-model-util
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / TypeDefinitions.java
index 117375d21d5de6f22c7abd92600d8e98e745577d..8b8ba8d35b034121229d448ffd02ff11534d68eb 100644 (file)
@@ -65,84 +65,99 @@ final class TypeDefinitions {
             type.getDefaultValue(), type.getLengthConstraints());
     }
 
-    static boolean equals(final BinaryTypeDefinition type, final Object obj) {
-        if (type == obj) {
-            return true;
-        }
+    static int hashCode(final BitsTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getBits());
+    }
 
-        final BinaryTypeDefinition other = castIfEquals(BinaryTypeDefinition.class, type, obj);
-        return other != null && type.getLengthConstraints().equals(other.getLengthConstraints());
+
+    static int hashCode(final BooleanTypeDefinition type) {
+        return basicHashCode(type);
     }
 
-    static String toString(final BinaryTypeDefinition type) {
-        return toStringHelper(type).add("length", type.getLengthConstraints()).toString();
+    static int hashCode(final DecimalTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getFractionDigits(), type.getRangeConstraints());
     }
 
-    static int hashCode(final BitsTypeDefinition type) {
+    static int hashCode(final EmptyTypeDefinition type) {
+        return basicHashCode(type);
+    }
+
+    static int hashCode(final EnumTypeDefinition type) {
         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getBits());
+            type.getDefaultValue(), type.getValues());
     }
 
-    static boolean equals(final BitsTypeDefinition type, final Object obj) {
-        if (type == obj) {
-            return true;
-        }
+    static int hashCode(final IdentityrefTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getIdentity());
+    }
 
-        final BitsTypeDefinition other = castIfEquals(BitsTypeDefinition.class, type, obj);
-        return other != null && type.getBits().equals(other.getBits());
+    static int hashCode(final InstanceIdentifierTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.requireInstance());
     }
 
-    static String toString(final BitsTypeDefinition type) {
-        return toStringHelper(type).add("bits", type.getBits()).toString();
+    static int hashCode(final IntegerTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getRangeConstraints());
     }
 
-    static int hashCode(final BooleanTypeDefinition type) {
-        return basicHashCode(type);
+    static int hashCode(final LeafrefTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getPathStatement());
     }
 
-    static boolean equals(final BooleanTypeDefinition type, final Object obj) {
-        return type == obj || castIfEquals(BooleanTypeDefinition.class, type, obj) != null;
+    static int hashCode(final StringTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getLengthConstraints(), type.getPatternConstraints());
     }
 
-    static String toString(final BooleanTypeDefinition type) {
-        return toStringHelper(type).toString();
+    static int hashCode(final UnionTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getTypes());
     }
 
-    static int hashCode(final DecimalTypeDefinition type) {
+    static int hashCode(final UnsignedIntegerTypeDefinition type) {
         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getFractionDigits(), type.getRangeConstraints());
+            type.getDefaultValue(), type.getRangeConstraints());
     }
 
-    static boolean equals(final DecimalTypeDefinition type, final Object obj) {
+    static boolean equals(final BinaryTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
         }
 
-        final DecimalTypeDefinition other = castIfEquals(DecimalTypeDefinition.class, type, obj);
-        return other != null && type.getFractionDigits().equals(other.getFractionDigits())
-                && type.getRangeConstraints().equals(other.getRangeConstraints());
+        final BinaryTypeDefinition other = castIfEquals(BinaryTypeDefinition.class, type, obj);
+        return other != null && type.getLengthConstraints().equals(other.getLengthConstraints());
     }
 
-    static String toString(final DecimalTypeDefinition type) {
-        return toStringHelper(type).add("fractionDigits", type.getFractionDigits())
-                .add("range", type.getRangeConstraints()).toString();
-    }
+    static boolean equals(final BitsTypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
 
-    static int hashCode(final EmptyTypeDefinition type) {
-        return basicHashCode(type);
+        final BitsTypeDefinition other = castIfEquals(BitsTypeDefinition.class, type, obj);
+        return other != null && type.getBits().equals(other.getBits());
     }
 
-    static boolean equals(final EmptyTypeDefinition type, final Object obj) {
-        return type == obj || castIfEquals(EmptyTypeDefinition.class, type, obj) != null;
+    static boolean equals(final BooleanTypeDefinition type, final Object obj) {
+        return type == obj || castIfEquals(BooleanTypeDefinition.class, type, obj) != null;
     }
 
-    static String toString(final EmptyTypeDefinition type) {
-        return toStringHelper(type).toString();
+    static boolean equals(final DecimalTypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final DecimalTypeDefinition other = castIfEquals(DecimalTypeDefinition.class, type, obj);
+        return other != null && type.getFractionDigits().equals(other.getFractionDigits())
+                && type.getRangeConstraints().equals(other.getRangeConstraints());
     }
 
-    static int hashCode(final EnumTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getValues());
+    static boolean equals(final EmptyTypeDefinition type, final Object obj) {
+        return type == obj || castIfEquals(EmptyTypeDefinition.class, type, obj) != null;
     }
 
     static boolean equals(final EnumTypeDefinition type, final Object obj) {
@@ -154,15 +169,6 @@ final class TypeDefinitions {
         return other != null && type.getValues().equals(other.getValues());
     }
 
-    static String toString(final EnumTypeDefinition type) {
-        return toStringHelper(type).add("values", type.getValues()).toString();
-    }
-
-    static int hashCode(final IdentityrefTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getIdentity());
-    }
-
     static boolean equals(final IdentityrefTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -172,15 +178,6 @@ final class TypeDefinitions {
         return other != null && type.getIdentity().equals(other.getIdentity());
     }
 
-    static String toString(final IdentityrefTypeDefinition type) {
-        return toStringHelper(type).add("identity", type.getIdentity()).toString();
-    }
-
-    static int hashCode(final InstanceIdentifierTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.requireInstance());
-    }
-
     static boolean equals(final InstanceIdentifierTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -190,15 +187,6 @@ final class TypeDefinitions {
         return other != null && type.requireInstance() == other.requireInstance();
     }
 
-    static String toString(final InstanceIdentifierTypeDefinition type) {
-        return toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
-    }
-
-    static int hashCode(final IntegerTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getRangeConstraints());
-    }
-
     static boolean equals(final IntegerTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -208,33 +196,15 @@ final class TypeDefinitions {
         return other != null && type.getRangeConstraints().equals(other.getRangeConstraints());
     }
 
-    static String toString(final IntegerTypeDefinition type) {
-        return toStringHelper(type).add("range", type.getRangeConstraints()).toString();
-    }
-
-    static int hashCode(final LeafrefTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getPathStatement());
-    }
-
     static boolean equals(final LeafrefTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
         }
 
-        final LeafrefTypeDefinition other =castIfEquals(LeafrefTypeDefinition.class, type, obj);
+        final LeafrefTypeDefinition other = castIfEquals(LeafrefTypeDefinition.class, type, obj);
         return other != null && type.getPathStatement().equals(other.getPathStatement());
     }
 
-    static String toString(final LeafrefTypeDefinition type) {
-        return toStringHelper(type).add("pathStatement", type.getPathStatement()).toString();
-    }
-
-    static int hashCode(final StringTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getLengthConstraints(), type.getPatternConstraints());
-    }
-
     static boolean equals(final StringTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -245,16 +215,6 @@ final class TypeDefinitions {
                 && type.getPatternConstraints().equals(other.getPatternConstraints());
     }
 
-    static String toString(final StringTypeDefinition type) {
-        return toStringHelper(type).add("length", type.getLengthConstraints())
-                .add("patterns", type.getPatternConstraints()).toString();
-    }
-
-    static int hashCode(final UnionTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getTypes());
-    }
-
     static boolean equals(final UnionTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -264,15 +224,6 @@ final class TypeDefinitions {
         return other != null && type.getTypes().equals(other.getTypes());
     }
 
-    static String toString(final UnionTypeDefinition type) {
-        return toStringHelper(type).add("types", type.getTypes()).toString();
-    }
-
-    static int hashCode(final UnsignedIntegerTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getRangeConstraints());
-    }
-
     static boolean equals(final UnsignedIntegerTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -282,6 +233,56 @@ final class TypeDefinitions {
         return other != null && type.getRangeConstraints().equals(other.getRangeConstraints());
     }
 
+    static String toString(final BinaryTypeDefinition type) {
+        return toStringHelper(type).add("length", type.getLengthConstraints()).toString();
+    }
+
+    static String toString(final BitsTypeDefinition type) {
+        return toStringHelper(type).add("bits", type.getBits()).toString();
+    }
+
+    static String toString(final BooleanTypeDefinition type) {
+        return toStringHelper(type).toString();
+    }
+
+    static String toString(final DecimalTypeDefinition type) {
+        return toStringHelper(type).add("fractionDigits", type.getFractionDigits())
+                .add("range", type.getRangeConstraints()).toString();
+    }
+
+    static String toString(final EmptyTypeDefinition type) {
+        return toStringHelper(type).toString();
+    }
+
+    static String toString(final EnumTypeDefinition type) {
+        return toStringHelper(type).add("values", type.getValues()).toString();
+    }
+
+    static String toString(final IdentityrefTypeDefinition type) {
+        return toStringHelper(type).add("identity", type.getIdentity()).toString();
+    }
+
+    static String toString(final InstanceIdentifierTypeDefinition type) {
+        return toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
+    }
+
+    static String toString(final IntegerTypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraints()).toString();
+    }
+
+    static String toString(final LeafrefTypeDefinition type) {
+        return toStringHelper(type).add("pathStatement", type.getPathStatement()).toString();
+    }
+
+    static String toString(final StringTypeDefinition type) {
+        return toStringHelper(type).add("length", type.getLengthConstraints())
+                .add("patterns", type.getPatternConstraints()).toString();
+    }
+
+    static String toString(final UnionTypeDefinition type) {
+        return toStringHelper(type).add("types", type.getTypes()).toString();
+    }
+
     static String toString(final UnsignedIntegerTypeDefinition type) {
         return toStringHelper(type).add("range", type.getRangeConstraints()).toString();
     }