当前位置: 首页>>代码示例>>Java>>正文


Java LongValue类代码示例

本文整理汇总了Java中com.google.cloud.datastore.LongValue的典型用法代码示例。如果您正苦于以下问题:Java LongValue类的具体用法?Java LongValue怎么用?Java LongValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LongValue类属于com.google.cloud.datastore包,在下文中一共展示了LongValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUnmarshalToObject_List

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Test
public void testUnmarshalToObject_List() {
	// Setup
	Key key = Key.newBuilder("project", "kind", 1).build();
	Entity entity = Entity.newBuilder(key)
			.set("object",
					Arrays.asList(DoubleValue.of(3.14), LongValue.of(42),
							StringValue.of("hello")))
			.set("list",
					Arrays.asList(DoubleValue.of(3.14), LongValue.of(42),
							StringValue.of("hello")))
			.set("linkedList", Arrays.asList(DoubleValue.of(3.14), LongValue.of(42),
					StringValue.of("hello")))
			.build();
	Unmarshaller unmarshaller = new Unmarshaller();
	TestBean bean = new TestBean();
	bean.linkedList = new LinkedList<Object>();

	// Exercise
	unmarshaller.unmarshalToObject(entity, bean);

	// Verify
	Assert.assertThat((List<?>) bean.object, contains(3.14, 42L, "hello"));
	Assert.assertThat(bean.list, contains(3.14, 42L, "hello"));
	Assert.assertThat(bean.linkedList, contains(3.14, 42L, "hello"));
	Assert.assertThat(bean.linkedList, instanceOf(LinkedList.class));
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:28,代码来源:UnmarshallerTests.java

示例2: toDatastore

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return LongValue.newBuilder((int) input);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:IntegerMapper.java

示例3: toModel

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  Long l = ((LongValue) input).get();
  if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
    throw new MappingException(String.format("Value %d is out of range for integer type", l));
  }
  return l.intValue();
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:12,代码来源:IntegerMapper.java

示例4: toDatastore

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return LongValue.newBuilder((short) input);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:ShortMapper.java

示例5: toModel

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  Long l = ((LongValue) input).get();
  if (l < Short.MIN_VALUE || l > Short.MAX_VALUE) {
    throw new MappingException(String.format("Value %d is out of range for short type", l));
  }
  return l.shortValue();
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:12,代码来源:ShortMapper.java

示例6: toDatastore

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  ValueBuilder<?, ?, ?> builder;
  if (input == null) {
    builder = NullValue.newBuilder();
  } else if (input instanceof Long) {
    builder = LongValue.newBuilder((long) input);
  } else if (input instanceof Double) {
    builder = DoubleValue.newBuilder((double) input);
  } else if (input instanceof Boolean) {
    builder = BooleanValue.newBuilder((boolean) input);
  } else if (input instanceof String) {
    builder = StringValue.newBuilder((String) input);
  } else if (input instanceof DatastoreKey) {
    builder = KeyValue.newBuilder(((DatastoreKey) input).nativeKey());
  } else if (input instanceof GeoLocation) {
    GeoLocation geoLocation = (GeoLocation) input;
    builder = LatLngValue
        .newBuilder(LatLng.of(geoLocation.getLatitude(), geoLocation.getLongitude()));
  } else if (input instanceof Map) {
    @SuppressWarnings("unchecked")
    Map<String, ?> map = (Map<String, ?>) input;
    FullEntity.Builder<IncompleteKey> entityBuilder = FullEntity.newBuilder();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
      String key = entry.getKey();
      entityBuilder.set(key, toDatastore(entry.getValue()).build());
    }
    builder = EntityValue.newBuilder(entityBuilder.build());
  } else {
    throw new MappingException(String.format("Unsupported type: %s", input.getClass().getName()));
  }
  return builder;
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:34,代码来源:CatchAllMapper.java

示例7: toModel

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  Object javaValue;
  if (input instanceof NullValue) {
    javaValue = null;
  } else if (input instanceof StringValue) {
    javaValue = input.get();
  } else if (input instanceof LongValue) {
    javaValue = input.get();
  } else if (input instanceof DoubleValue) {
    javaValue = input.get();
  } else if (input instanceof BooleanValue) {
    javaValue = input.get();
  } else if (input instanceof KeyValue) {
    javaValue = new DefaultDatastoreKey(((KeyValue) input).get());
  } else if (input instanceof LatLngValue) {
    LatLng latLong = ((LatLngValue) input).get();
    javaValue = new GeoLocation(latLong.getLatitude(), latLong.getLongitude());
  } else if (input instanceof EntityValue) {
    EntityValue entityValue = (EntityValue) input;
    FullEntity<?> entity = entityValue.get();
    Map<String, Object> map = new HashMap<>();
    for (String property : entity.getNames()) {
      map.put(property, toModel(entity.getValue(property)));
    }
    javaValue = map;
  } else {
    throw new MappingException(String.format("Unsupported type %s", input.getClass().getName()));
  }
  return javaValue;
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:32,代码来源:CatchAllMapper.java

示例8: toDatastore

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return LongValue.newBuilder((long) input);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:LongMapper.java

示例9: toModel

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  return ((LongValue) input).get();
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:LongMapper.java

示例10: testIndex_3

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Test(expected = IndexingException.class)
public void testIndex_3() {
  LongValue input = LongValue.of(5L);
  try {
    Value<?> output = indexer.index(input);
  } catch (Exception exp) {
    LOGGER.log(Level.INFO, exp.toString());
    throw exp;
  }
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:11,代码来源:LowerCaseStringIndexerTest.java

示例11: testIndex_5

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Test(expected = IndexingException.class)
public void testIndex_5() {
  Value<?>[] inputArray = { StringValue.of("Hello"), NullValue.of(), LongValue.of(5L) };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  try {
    ListValue output = (ListValue) indexer.index(input);
  } catch (Exception exp) {
    LOGGER.log(Level.INFO, exp.toString());
    throw exp;
  }
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:12,代码来源:UpperCaseStringListIndexerTest.java

示例12: toDatastore

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  return LongValue.newBuilder((byte) input);
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:8,代码来源:ByteMapper.java

示例13: toModel

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  Long l = ((LongValue) input).get();
  if (l < Byte.MIN_VALUE || l > Byte.MAX_VALUE) {
    throw new MappingException(String.format("Value %d is out of range for byte type", l));
  }
  return l.byteValue();
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:12,代码来源:ByteMapper.java

示例14: toDatastore

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
  if (input == null) {
    return NullValue.newBuilder();
  }
  try {
    BigDecimal n = (BigDecimal) input;
    n = n.movePointRight(fractionalDigits);
    return LongValue.newBuilder(n.longValueExact());
  } catch (Exception e) {
    throw new MappingException(e);
  }
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:14,代码来源:CurrencyMapper.java

示例15: toModel

import com.google.cloud.datastore.LongValue; //导入依赖的package包/类
@Override
public Object toModel(Value<?> input) {
  if (input instanceof NullValue) {
    return null;
  }
  BigDecimal n = new BigDecimal(((LongValue) input).get());
  n = n.movePointLeft(fractionalDigits);
  return n;
}
 
开发者ID:sai-pullabhotla,项目名称:catatumbo,代码行数:10,代码来源:CurrencyMapper.java


注:本文中的com.google.cloud.datastore.LongValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。