diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/classification/InterfaceAudience.java b/typesystem/src/main/java/org/apache/hadoop/metadata/classification/InterfaceAudience.java new file mode 100644 index 0000000..41c5e93 --- /dev/null +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/classification/InterfaceAudience.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.metadata.classification; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Annotation to mark methods for consumption. + */ +@InterfaceAudience.Public +public class InterfaceAudience { + private InterfaceAudience() { + } + + @Documented + @Retention(RetentionPolicy.RUNTIME) + public @interface Private { + } + + @Documented + @Retention(RetentionPolicy.RUNTIME) + public @interface LimitedPrivate { + String[] value(); + } + + @Documented + @Retention(RetentionPolicy.RUNTIME) + public @interface Public { + } +} diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Referenceable.java b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Referenceable.java index e60ebfc..c3285c7 100644 --- a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Referenceable.java +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Referenceable.java @@ -20,6 +20,7 @@ package org.apache.hadoop.metadata.typesystem; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.apache.hadoop.metadata.classification.InterfaceAudience; import org.apache.hadoop.metadata.typesystem.persistence.Id; import java.util.List; @@ -60,11 +61,12 @@ public class Referenceable extends Struct implements IReferenceableInstance { } /** - * @nopublic only use during deserialization + * Not public - only use during deserialization * @param guid * @param typeName * @param values */ + @InterfaceAudience.Private public Referenceable(String guid, String typeName, Map<String, Object> values, List<String> _traitNames, Map<String, IStruct> _traits) { diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Struct.java b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Struct.java index b5985e4..d12ee16 100644 --- a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Struct.java +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/Struct.java @@ -18,6 +18,8 @@ package org.apache.hadoop.metadata.typesystem; +import org.apache.hadoop.metadata.classification.InterfaceAudience; + import java.util.HashMap; import java.util.Map; @@ -28,12 +30,10 @@ public class Struct implements IStruct { public Struct(String typeName) { this.typeName = typeName; - values = new HashMap<String, Object>(); + values = new HashMap<>(); } - /** - @nopublic - */ + @InterfaceAudience.Private public Struct(String typeName, Map<String, Object> values) { this(typeName); this.values.putAll(values); @@ -54,10 +54,7 @@ public class Struct implements IStruct { values.put(attrName, value); } - /** - * @nopublic - * @return - */ + @InterfaceAudience.Private public Map<String, Object> getValuesMap() { return values; } diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/AttributeDefinition.java b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/AttributeDefinition.java index d75fca8..307241d 100644 --- a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/AttributeDefinition.java +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/AttributeDefinition.java @@ -18,6 +18,8 @@ package org.apache.hadoop.metadata.typesystem.types; +import com.google.common.base.Preconditions; + public final class AttributeDefinition { public final String name; @@ -42,6 +44,9 @@ public final class AttributeDefinition { public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite, boolean isUnique, boolean isIndexable, String reverseAttributeName) { + Preconditions.checkNotNull(name); + Preconditions.checkNotNull(dataTypeName); + this.name = name; this.dataTypeName = dataTypeName; this.multiplicity = multiplicity; @@ -64,9 +69,9 @@ public final class AttributeDefinition { if (!dataTypeName.equals(that.dataTypeName)) return false; if (!multiplicity.equals(that.multiplicity)) return false; if (!name.equals(that.name)) return false; - if (reverseAttributeName != null ? !reverseAttributeName.equals(that.reverseAttributeName) - : that - .reverseAttributeName != null) + if (reverseAttributeName != null + ? !reverseAttributeName.equals(that.reverseAttributeName) + : that.reverseAttributeName != null) return false; return true; diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/HierarchicalTypeDefinition.java b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/HierarchicalTypeDefinition.java index 6a03315..4c87c14 100644 --- a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/HierarchicalTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/HierarchicalTypeDefinition.java @@ -19,6 +19,7 @@ package org.apache.hadoop.metadata.typesystem.types; import com.google.common.collect.ImmutableList; +import org.apache.hadoop.metadata.classification.InterfaceAudience; public class HierarchicalTypeDefinition<T extends HierarchicalType> extends StructTypeDefinition { @@ -26,14 +27,15 @@ public class HierarchicalTypeDefinition<T extends HierarchicalType> extends Stru public final String hierarchicalMetaTypeName; /** - * Used for json deserialization only - * @nopublic + * Used for json deserialization only. + * not intended public consumption * @param hierarchicalMetaTypeName * @param typeName * @param superTypes * @param attributeDefinitions * @throws ClassNotFoundException */ + @InterfaceAudience.Private public HierarchicalTypeDefinition(String hierarchicalMetaTypeName, String typeName, String[] superTypes, AttributeDefinition[] attributeDefinitions) diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java index 6b13f55..5433cd5 100644 --- a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/TypeSystem.java @@ -20,6 +20,7 @@ package org.apache.hadoop.metadata.typesystem.types; import com.google.common.collect.ImmutableList; import org.apache.hadoop.metadata.MetadataException; +import org.apache.hadoop.metadata.classification.InterfaceAudience; import org.apache.hadoop.metadata.typesystem.TypesDef; import javax.inject.Singleton; @@ -37,6 +38,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @Singleton +@InterfaceAudience.Private public class TypeSystem { private static final TypeSystem INSTANCE = new TypeSystem(); public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); @@ -59,9 +61,9 @@ public class TypeSystem { } /** - * This is only used for testing prurposes. - * @nonpublic + * This is only used for testing purposes. Not intended for public use. */ + @InterfaceAudience.Private public void reset() { initialize(); } diff --git a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/utils/TypesUtil.java b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/utils/TypesUtil.java index 7a66a3b..b371f1f 100644 --- a/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/utils/TypesUtil.java +++ b/typesystem/src/main/java/org/apache/hadoop/metadata/typesystem/types/utils/TypesUtil.java @@ -47,6 +47,11 @@ public class TypesUtil { return new AttributeDefinition(name, dataType, Multiplicity.OPTIONAL, false, null); } + public static AttributeDefinition createRequiredAttrDef(String name, + String dataType) { + return new AttributeDefinition(name, dataType, Multiplicity.REQUIRED, false, null); + } + public static AttributeDefinition createUniqueRequiredAttrDef(String name, IDataType dataType) { return new AttributeDefinition(name, dataType.getName(),