com.github.TKnudsen.ComplexDataObject.data.DataSchemaEntry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
The newest version!
package com.github.TKnudsen.ComplexDataObject.data;
import com.github.TKnudsen.ComplexDataObject.data.interfaces.IKeyValueProvider;
/**
*
* Title:
*
*
*
* Description: Describes individual attributes of key-value data structures.
*
*
*
* Copyright: Copyright (c) 2016
*
*
* @author Juergen Bernard
* @version 1.0
*/
public class DataSchemaEntry {
protected final String name;
protected final Class type;
protected final T defaultValue;
protected final DataSchema typeSchema;
public DataSchemaEntry(String name, Class type, T defaultValue) {
this(name, type, defaultValue, null);
}
public DataSchemaEntry(String name, Class type, T defaultValue, DataSchema typeSchema) {
if (!IKeyValueProvider.class.isAssignableFrom(type) && typeSchema != null) {
throw new IllegalArgumentException("types with a defined typeSchema must inherit IDataObject");
}
this.name = name;
this.type = type;
this.typeSchema = typeSchema;
this.defaultValue = defaultValue;
}
public String getName() {
return name;
}
public Class getType() {
return type;
}
public T getDefaultValue() {
return defaultValue;
}
public DataSchema getTypeSchema() {
return typeSchema;
}
public boolean isComplexType() {
return typeSchema != null;
}
@Override
public String toString() {
String output = "";
output += ("Name: " + name + "\t" + "Type: " + type.getSimpleName() + "\t" + "Default Value: " + defaultValue);
return output;
}
}