本文整理匯總了Java中com.redhat.lightblue.metadata.types.BooleanType類的典型用法代碼示例。如果您正苦於以下問題:Java BooleanType類的具體用法?Java BooleanType怎麽用?Java BooleanType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BooleanType類屬於com.redhat.lightblue.metadata.types包,在下文中一共展示了BooleanType類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTranslate_SimpleField_Boolean
import com.redhat.lightblue.metadata.types.BooleanType; //導入依賴的package包/類
@Test
public void testTranslate_SimpleField_Boolean() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
new Attribute("key", "true")
});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new SimpleField("key", BooleanType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"key\":true,\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
示例2: rawValueToJson
import com.redhat.lightblue.metadata.types.BooleanType; //導入依賴的package包/類
private static JsonNode rawValueToJson(Object value) {
if(value instanceof Number) {
if(value instanceof Float || value instanceof Double) {
return DoubleType.TYPE.toJson(JsonNodeFactory.instance,value);
} else {
return IntegerType.TYPE.toJson(JsonNodeFactory.instance,value);
}
} else if(value instanceof Date) {
return DateType.TYPE.toJson(JsonNodeFactory.instance,value);
} else if(value instanceof Boolean) {
return BooleanType.TYPE.toJson(JsonNodeFactory.instance,value);
} else if(value==null) {
return JsonNodeFactory.instance.nullNode();
} else {
return JsonNodeFactory.instance.textNode(value.toString());
}
}
示例3: getTypeForClass
import com.redhat.lightblue.metadata.types.BooleanType; //導入依賴的package包/類
private Type getTypeForClass(Class<?> type) {
if (type.equals(String.class) || type.isEnum()) {
return StringType.TYPE;
}
if (type.equals(boolean.class) || type.equals(Boolean.class)) {
return BooleanType.TYPE;
}
if (type.equals(Date.class) || Temporal.class.isAssignableFrom(type)) {
return DateType.TYPE;
}
if (type.equals(BigDecimal.class)) {
return BigDecimalType.TYPE;
}
if (type.equals(BigInteger.class)) {
return BigIntegerType.TYPE;
}
if (type.equals(byte[].class)) {
return BinaryType.TYPE;
}
if (type.equals(double.class) || type.equals(Double.class)) {
return DoubleType.TYPE;
}
if (type.equals(int.class) || type.equals(Integer.class)) {
return IntegerType.TYPE;
}
if (Iterable.class.isAssignableFrom(type)) {
return ArrayType.TYPE;
}
// TODO: Reference type, UUID type
return ObjectType.TYPE;
}