本文整理了Java中java.lang.Short.<init>()
方法的一些代码示例,展示了Short.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Short.<init>()
方法的具体详情如下:
包路径:java.lang.Short
类名称:Short
方法名:<init>
[英]Constructs a new Short from the specified string.
[中]从指定的字符串构造新的Short。
代码示例来源:origin: log4j/log4j
/**
* Returns a Short instance representing the specified short.
* Short.valueOf was added in JDK 1.5.
*
* @param b a short value.
* @return a Byte instance representing b.
*/
protected static Short valueOf(final short b) {
return new Short(b);
}
代码示例来源:origin: commons-lang/commons-lang
/**
* Gets the value as a Short instance.
*
* @return the value as a Short, never null
*/
public Object getValue() {
return new Short(this.value);
}
代码示例来源:origin: google/j2objc
/**
* Asserts that two shorts are equal. If they are not
* an AssertionFailedError is thrown with the given message.
*/
static public void assertEquals(String message, short expected, short actual) {
assertEquals(message, new Short(expected), new Short(actual));
}
代码示例来源:origin: commons-lang/commons-lang
/**
* Gets this mutable as an instance of Short.
*
* @return a Short instance containing the value from this mutable, never null
*/
public Short toShort() {
return new Short(shortValue());
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Creates a map of the classes fields.
*/
protected static Object getParamArg(Class cl) {
if (!cl.isPrimitive())
return null;
else if (boolean.class.equals(cl))
return Boolean.FALSE;
else if (byte.class.equals(cl))
return new Byte((byte) 0);
else if (short.class.equals(cl))
return new Short((short) 0);
else if (char.class.equals(cl))
return new Character((char) 0);
else if (int.class.equals(cl))
return Integer.valueOf(0);
else if (long.class.equals(cl))
return Long.valueOf(0);
else if (float.class.equals(cl))
return Float.valueOf(0);
else if (double.class.equals(cl))
return Double.valueOf(0);
else
throw new UnsupportedOperationException();
}
代码示例来源:origin: redisson/redisson
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Short(getValue());
}
代码示例来源:origin: google/guava
@Generates
private Short generateShortObject() {
return new Short(generateShort());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapFromProperties() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Properties input = new Properties();
input.setProperty("4", "5");
input.setProperty("6", "7");
bw.setPropertyValue("shortMap", input);
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMap() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Map<String, String> input = new HashMap<>();
input.put("4", "5");
input.put("6", "7");
bw.setPropertyValue("shortMap", input);
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: Activiti/Activiti
public Object getValue(ValueFields valueFields) {
if (valueFields.getLongValue() != null) {
return new Short(valueFields.getLongValue().shortValue());
}
return null;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapProperty() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Map<String, String> input = new HashMap<>();
input.put("4", "5");
input.put("6", "7");
rbd.getPropertyValues().add("shortMap", input);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapMapConstructorWithSameRefAndNoConversion() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Map<Short, Integer> input = new HashMap<>();
input.put(new Short((short) 1), new Integer(0));
input.put(new Short((short) 2), new Integer(3));
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertSame(gb.getPlainMap(), gb.getShortMap());
assertEquals(2, gb.getShortMap().size());
assertEquals(new Integer(0), gb.getShortMap().get(new Short("1")));
assertEquals(new Integer(3), gb.getShortMap().get(new Short("2")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapElement() {
GenericBean<?> gb = new GenericBean<>();
gb.setShortMap(new HashMap<>());
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("shortMap[4]", "5");
assertEquals(new Integer(5), bw.getPropertyValue("shortMap[4]"));
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericSetMapConstructor() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Set<String> input = new HashSet<>();
input.add("4");
input.add("5");
Map<String, String> input2 = new HashMap<>();
input2.put("4", "5");
input2.put("6", "7");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue(input2);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertTrue(gb.getIntegerSet().contains(new Integer(4)));
assertTrue(gb.getIntegerSet().contains(new Integer(5)));
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapResourceConstructor() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Map<String, String> input = new HashMap<>();
input.put("4", "5");
input.put("6", "7");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue("http://localhost:8080");
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericSetMapFactoryMethod() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
rbd.setFactoryMethodName("createInstance");
Set<String> input = new HashSet<>();
input.add("4");
input.add("5");
Map<String, String> input2 = new HashMap<>();
input2.put("4", "5");
input2.put("6", "7");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue(input2);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertTrue(gb.getIntegerSet().contains(new Integer(4)));
assertTrue(gb.getIntegerSet().contains(new Integer(5)));
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapMapFactoryMethod() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
rbd.setFactoryMethodName("createInstance");
Map<String, String> input = new HashMap<>();
input.put("1", "0");
input.put("2", "3");
Map<String, String> input2 = new HashMap<>();
input2.put("4", "5");
input2.put("6", "7");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue(input2);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertEquals("0", gb.getPlainMap().get("1"));
assertEquals("3", gb.getPlainMap().get("2"));
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapResourceFactoryMethod() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
rbd.setFactoryMethodName("createInstance");
Map<String, String> input = new HashMap<>();
input.put("4", "5");
input.put("6", "7");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue("http://localhost:8080");
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapMapConstructor() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Map<String, String> input = new HashMap<>();
input.put("1", "0");
input.put("2", "3");
Map<String, String> input2 = new HashMap<>();
input2.put("4", "5");
input2.put("6", "7");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue(input2);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertNotSame(gb.getPlainMap(), gb.getShortMap());
assertEquals(2, gb.getPlainMap().size());
assertEquals("0", gb.getPlainMap().get("1"));
assertEquals("3", gb.getPlainMap().get("2"));
assertEquals(2, gb.getShortMap().size());
assertEquals(new Integer(5), gb.getShortMap().get(new Short("4")));
assertEquals(new Integer(7), gb.getShortMap().get(new Short("6")));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGenericMapMapConstructorWithSameRefAndConversion() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Map<String, String> input = new HashMap<>();
input.put("1", "0");
input.put("2", "3");
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
rbd.getConstructorArgumentValues().addGenericArgumentValue(input);
bf.registerBeanDefinition("genericBean", rbd);
GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean");
assertNotSame(gb.getPlainMap(), gb.getShortMap());
assertEquals(2, gb.getPlainMap().size());
assertEquals("0", gb.getPlainMap().get("1"));
assertEquals("3", gb.getPlainMap().get("2"));
assertEquals(2, gb.getShortMap().size());
assertEquals(new Integer(0), gb.getShortMap().get(new Short("1")));
assertEquals(new Integer(3), gb.getShortMap().get(new Short("2")));
}
内容来源于网络,如有侵权,请联系作者删除!