use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testNestedFieldPathSpec.
@Test
public void testNestedFieldPathSpec() {
PathSpec p = RecordTest.fields().recordField().location();
Assert.assertEquals(p.toString(), "/recordField/location");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testMapWildcardPathSpec.
@Test
public void testMapWildcardPathSpec() {
PathSpec p = MapTest.fields().recordInlineMap().values().f();
Assert.assertEquals(p.toString(), "/recordInlineMap/*/f");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testMapWildcardPathSpec.
@Test
public void testMapWildcardPathSpec() {
PathSpec p = MapTest.fields().recordInlineMap().values().f();
Assert.assertEquals(p.toString(), "/recordInlineMap/*/f");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testArrayWildcardPathSpec.
@Test
public void testArrayWildcardPathSpec() {
PathSpec p = ArrayTest.fields().recordInlineArray().items().f();
Assert.assertEquals(p.toString(), "/recordInlineArray/*/f");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class GeneratePatchMethodInterceptor method interpretSetModeAndSet.
private void interpretSetModeAndSet(String propertyName, Object arg, SetMode setMode) {
PathSpec pathSpec = new PathSpec(_pathSpec.getPathComponents(), propertyName);
boolean doSet = false;
switch(setMode) {
case DISALLOW_NULL:
if (arg == null)
throw new NullPointerException("Cannot set field " + pathSpec + " on " + _schema.getFullName() + " to null");
doSet = true;
break;
case IGNORE_NULL:
if (arg != null)
doSet = true;
break;
case REMOVE_IF_NULL:
doSet = true;
break;
case REMOVE_OPTIONAL_IF_NULL:
if (_schema.getField(propertyName).getOptional())
doSet = true;
else if (arg == null)
throw new IllegalArgumentException("Cannot remove mandatory field " + pathSpec + " on " + _schema.getFullName());
break;
}
if (doSet) {
PatchOperation patchOp = arg == null ? PatchOpFactory.REMOVE_FIELD_OP : PatchOpFactory.setFieldOp(coerceSetValue(arg));
_patchTree.addOperation(pathSpec, patchOp);
}
}
Aggregations