本文整理汇总了Java中com.redhat.lightblue.metadata.Fields.addNew方法的典型用法代码示例。如果您正苦于以下问题:Java Fields.addNew方法的具体用法?Java Fields.addNew怎么用?Java Fields.addNew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.metadata.Fields
的用法示例。
在下文中一共展示了Fields.addNew方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldGenerateArrayFieldTypesForSimpleArrayElements
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test
public void shouldGenerateArrayFieldTypesForSimpleArrayElements() {
class HasArray {
public List<String> getFoobars() {
return Arrays.asList("foo", "bars");
}
public void setFoobars(List<String> foobars) {
}
}
EntitySchema expectedSchema = new EntitySchema("hasArray");
ArrayField expectedArrayField = new ArrayField("foobars", new SimpleArrayElement(StringType.TYPE));
Fields expectedFields = expectedSchema.getFields();
expectedFields.addNew(expectedArrayField);
EntitySchema schema = generator.generateSchema(HasArray.class);
assertThat(schema.getFields(), equalToFields(expectedFields));
}
示例2: addFieldToParent
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
/**
* Adds the <code>newField</cod> to the <code>newFieldPath</code>.
* @param md - {@link EntityMetadata}
* @param newFieldPath - {@link Path} to add
* @param newField - {@link Field} to add at the <code>newFieldPath</code>
*/
private void addFieldToParent(EntityMetadata md, Path newFieldPath, Field newField){
Fields fields;
if(newFieldPath.numSegments() == 1){
fields = md.getFields();
}
else{
Path parentPath = newFieldPath.prefix(-1);
FieldTreeNode parent = md.resolve(parentPath);
if(parent instanceof ObjectField){
fields = ((ObjectField) parent).getFields();
}
else if (parent instanceof ObjectArrayElement){
fields = ((ObjectArrayElement) parent).getFields();
}
else {
throw Error.get(MetadataConstants.ERR_FIELD_WRONG_TYPE, parentPath.toString());
}
}
fields.addNew(newField);
}
示例3: testBeforeCreateNewSchema_alreadyHasDefinedDnAndObjectClass
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
/**
* The fields that were defined should remain.
*/
@Test
public void testBeforeCreateNewSchema_alreadyHasDefinedDnAndObjectClass(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
SimpleField dnField = new SimpleField(LdapConstant.ATTRIBUTE_DN, StringType.TYPE);
fields.addNew(dnField);
ArrayField objectClassField = new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, new SimpleArrayElement(StringType.TYPE));
fields.addNew(objectClassField);
SimpleField objectClassCountField = new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#", IntegerType.TYPE);
fields.addNew(objectClassCountField);
LdapMetadataListener listener = new LdapMetadataListener();
listener.beforeCreateNewSchema(null, md);
assertTrue(md.getFields().has(LdapConstant.ATTRIBUTE_DN));
assertTrue(md.getFields().has(LdapConstant.ATTRIBUTE_OBJECT_CLASS));
assertTrue(md.getFields().has(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#"));
assertEquals(dnField, md.getFields().getField(LdapConstant.ATTRIBUTE_DN));
assertEquals(objectClassField, md.getFields().getField(LdapConstant.ATTRIBUTE_OBJECT_CLASS));
assertEquals(objectClassCountField, md.getFields().getField(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#"));
}
示例4: addFieldsFromBeanMirror
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
private void addFieldsFromBeanMirror(BeanMirror beanMirror, Fields fields,
Optional<Fields> maybeOriginal) {
for (FieldMirror fieldMirror : beanMirror.getFields()) {
String name = fieldMirror.name();
Optional<Field> maybeOriginalField = maybeOriginal.map(o -> o.getField(name));
Field field = getFieldFromFieldMirror(fieldMirror, maybeOriginalField);
field.setConstraints(getConstraintsForBeanField(fieldMirror));
fieldMirror.description().ifPresent(field::setDescription);
if (field instanceof SimpleField) {
SimpleField simpleField = (SimpleField) field;
getValueGeneratorForBeanField(fieldMirror).ifPresent(simpleField::setValueGenerator);
}
maybeOriginalField.ifPresent(original -> {
FieldAccess access = field.getAccess();
FieldAccess originalAccess = original.getAccess();
access.getFind().setRoles(originalAccess.getFind());
access.getInsert().setRoles(originalAccess.getInsert());
access.getUpdate().setRoles(originalAccess.getUpdate());
});
fields.addNew(field);
}
}
示例5: shouldGenerateObjectFieldTypes
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test
public void shouldGenerateObjectFieldTypes() {
class HasInnerObject {
public InnerObject getInnerObject() {
return new InnerObject();
}
public void setInnerObject(InnerObject innerObject) {
}
class InnerObject {
public String getFoo() {
return "foo";
}
public void setFoo(String foo) {
}
}
}
EntitySchema expectedSchema = new EntitySchema("hasInnerObject");
Fields expectedFields = expectedSchema.getFields();
ObjectField expectedObjectField = new ObjectField("innerObject");
expectedObjectField.getFields().addNew(new SimpleField("foo", StringType.TYPE));
expectedFields.addNew(expectedObjectField);
EntitySchema schema = generator.generateSchema(HasInnerObject.class);
assertThat(schema.getFields(), equalToFields(expectedFields));
}
示例6: shouldGenerateArrayFieldTypesForObjectArrayElements
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test
public void shouldGenerateArrayFieldTypesForObjectArrayElements() {
class HasObjectArray {
public List<SomeObject> getSomeObjects() {
return Arrays.asList(new SomeObject(), new SomeObject());
}
public void setSomeObjects(List<SomeObject> someObjects) {
}
class SomeObject {
public Integer getSomeNumber() {
return 42;
}
public void setSomeNumber(Integer someNumber) {
}
}
}
EntitySchema expectedSchema = new EntitySchema("hasObjectArray");
ObjectArrayElement expectedArrayElement = new ObjectArrayElement();
expectedArrayElement.getFields().addNew(new SimpleField("someNumber", IntegerType.TYPE));
ArrayField expectedArrayField = new ArrayField("someObjects", expectedArrayElement);
Fields expectedFields = expectedSchema.getFields();
expectedFields.addNew(expectedArrayField);
EntitySchema schema = generator.generateSchema(HasObjectArray.class);
assertThat(schema.getFields(), equalToFields(expectedFields));
}
示例7: testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongType
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongType(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_DN, IntegerType.TYPE));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例8: testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongField
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongField(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new ArrayField(LdapConstant.ATTRIBUTE_DN));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例9: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongType
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongType(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, StringType.TYPE));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例10: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongField
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongField(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例11: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementType
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementType(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, new SimpleArrayElement(IntegerType.TYPE)));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例12: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementField
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementField(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
ArrayField field = new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, new ObjectArrayElement());
fields.addNew(field);
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例13: testBeforeCreateNewSchema_alreadyHasDefinedObjectClassCount_butAsWrongType
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClassCount_butAsWrongType(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#", StringType.TYPE));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
示例14: testBeforeCreateNewSchema_alreadyHasDefinedObjectClassCount_butAsWrongField
import com.redhat.lightblue.metadata.Fields; //导入方法依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClassCount_butAsWrongField(){
EntityMetadata md = new EntityMetadata("fake");
setupEntityMetadata(md);
Fields fields = md.getEntitySchema().getFields();
fields.addNew(new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#"));
new LdapMetadataListener().beforeCreateNewSchema(null, md);
}