Commit dde33712 by Venkatesh Seetharam

Add unique and index attributes for types. Contributed by Venkatesh Seetharam

parent 6418f2c2
...@@ -24,6 +24,9 @@ public final class AttributeDefinition { ...@@ -24,6 +24,9 @@ public final class AttributeDefinition {
public final String dataTypeName; public final String dataTypeName;
public final Multiplicity multiplicity; public final Multiplicity multiplicity;
public final boolean isComposite; public final boolean isComposite;
public final boolean isUnique;
public final boolean isIndexable;
/** /**
* If this is a reference attribute, then the name of the attribute on the Class * If this is a reference attribute, then the name of the attribute on the Class
* that this refers to. * that this refers to.
...@@ -32,10 +35,19 @@ public final class AttributeDefinition { ...@@ -32,10 +35,19 @@ public final class AttributeDefinition {
public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity,
boolean isComposite, String reverseAttributeName) { boolean isComposite, String reverseAttributeName) {
this(name, dataTypeName, multiplicity, isComposite, false, true, reverseAttributeName);
}
public AttributeDefinition(String name, String dataTypeName,
Multiplicity multiplicity, boolean isComposite, boolean isUnique,
boolean isIndexable, String reverseAttributeName) {
this.name = name; this.name = name;
this.dataTypeName = dataTypeName; this.dataTypeName = dataTypeName;
this.multiplicity = multiplicity; this.multiplicity = multiplicity;
this.isComposite = isComposite; this.isComposite = isComposite;
this.isUnique = isUnique;
this.isIndexable = isIndexable;
this.reverseAttributeName = reverseAttributeName; this.reverseAttributeName = reverseAttributeName;
} }
...@@ -47,6 +59,8 @@ public final class AttributeDefinition { ...@@ -47,6 +59,8 @@ public final class AttributeDefinition {
AttributeDefinition that = (AttributeDefinition) o; AttributeDefinition that = (AttributeDefinition) o;
if (isComposite != that.isComposite) return false; if (isComposite != that.isComposite) return false;
if (isUnique != that.isUnique) return false;
if (isIndexable != that.isIndexable) return false;
if (!dataTypeName.equals(that.dataTypeName)) return false; if (!dataTypeName.equals(that.dataTypeName)) return false;
if (!multiplicity.equals(that.multiplicity)) return false; if (!multiplicity.equals(that.multiplicity)) return false;
if (!name.equals(that.name)) return false; if (!name.equals(that.name)) return false;
...@@ -63,6 +77,8 @@ public final class AttributeDefinition { ...@@ -63,6 +77,8 @@ public final class AttributeDefinition {
result = 31 * result + dataTypeName.hashCode(); result = 31 * result + dataTypeName.hashCode();
result = 31 * result + multiplicity.hashCode(); result = 31 * result + multiplicity.hashCode();
result = 31 * result + (isComposite ? 1 : 0); result = 31 * result + (isComposite ? 1 : 0);
result = 31 * result + (isUnique ? 1 : 0);
result = 31 * result + (isIndexable ? 1 : 0);
result = 31 * result + (reverseAttributeName != null ? reverseAttributeName.hashCode() : 0); result = 31 * result + (reverseAttributeName != null ? reverseAttributeName.hashCode() : 0);
return result; return result;
} }
......
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
...@@ -20,13 +19,15 @@ ...@@ -20,13 +19,15 @@
package org.apache.hadoop.metadata.types; package org.apache.hadoop.metadata.types;
import org.apache.hadoop.metadata.MetadataException; import org.apache.hadoop.metadata.MetadataException;
import org.apache.hadoop.metadata.MetadataException;
public class AttributeInfo { public class AttributeInfo {
public final String name; public final String name;
private IDataType dataType; private IDataType dataType;
public final Multiplicity multiplicity; public final Multiplicity multiplicity;
public final boolean isComposite; public final boolean isComposite;
public final boolean isUnique;
public final boolean isIndexable;
/** /**
* If this is a reference attribute, then the name of the attribute on the Class * If this is a reference attribute, then the name of the attribute on the Class
* that this refers to. * that this refers to.
...@@ -39,6 +40,8 @@ public class AttributeInfo { ...@@ -39,6 +40,8 @@ public class AttributeInfo {
this.dataType = t.getDataType(IDataType.class, def.dataTypeName); this.dataType = t.getDataType(IDataType.class, def.dataTypeName);
this.multiplicity = def.multiplicity; this.multiplicity = def.multiplicity;
this.isComposite = def.isComposite; this.isComposite = def.isComposite;
this.isUnique = def.isUnique;
this.isIndexable = def.isIndexable;
this.reverseAttributeName = def.reverseAttributeName; this.reverseAttributeName = def.reverseAttributeName;
} }
...@@ -57,6 +60,8 @@ public class AttributeInfo { ...@@ -57,6 +60,8 @@ public class AttributeInfo {
", dataType=" + dataType + ", dataType=" + dataType +
", multiplicity=" + multiplicity + ", multiplicity=" + multiplicity +
", isComposite=" + isComposite + ", isComposite=" + isComposite +
", isUnique=" + isUnique +
", isIndexable=" + isIndexable +
", reverseAttributeName='" + reverseAttributeName + '\'' + ", reverseAttributeName='" + reverseAttributeName + '\'' +
'}'; '}';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment