本文整理匯總了Java中com.amazonaws.services.dynamodbv2.model.AttributeValue.setB方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributeValue.setB方法的具體用法?Java AttributeValue.setB怎麽用?Java AttributeValue.setB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.dynamodbv2.model.AttributeValue
的用法示例。
在下文中一共展示了AttributeValue.setB方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: attrValueOf
import com.amazonaws.services.dynamodbv2.model.AttributeValue; //導入方法依賴的package包/類
/**
* Set value to <code>null</code> by <code>withNULL(Boolean.TRUE)</code> if the specified value is null,
* or set it to <code>Boolean</code> by <code>setBOOL((Boolean) value)</code> if it's <code>Boolean</code>,
* or set it to <code>ByteBuffer</code> by <code>setB((ByteBuffer) value)</code> if it's <code>ByteBuffer</code>,
* otherwise, set it to String by <code>setS(N.stringOf(value))</code> for other types.
* That's to say all the types except Number/Boolean/ByteBuffer are defined to String.
*
* @param value
* @return
*/
public static AttributeValue attrValueOf(Object value) {
final AttributeValue attrVal = new AttributeValue();
if (value == null) {
attrVal.withNULL(Boolean.TRUE);
} else {
final Type<Object> type = N.typeOf(value.getClass());
if (type.isNumber()) {
attrVal.setN(type.stringOf(value));
} else if (type.isBoolean()) {
attrVal.setBOOL((Boolean) value);
} else if (type.isByteBuffer()) {
attrVal.setB((ByteBuffer) value);
} else {
attrVal.setS(type.stringOf(value));
}
}
return attrVal;
}