本文整理了Java中com.esotericsoftware.kryo.Kryo.isFinal()
方法的一些代码示例,展示了Kryo.isFinal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.isFinal()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:isFinal
[英]Returns true if the specified type is final. Final types can be serialized more efficiently because they are non-polymorphic.
This can be overridden to force non-final classes to be treated as final. Eg, if an application uses ArrayList extensively but never uses an ArrayList subclass, treating ArrayList as final could allow FieldSerializer to save 1-2 bytes per ArrayList field.
[中]如果指定的类型是final,则返回true。最终类型可以更有效地序列化,因为它们是非多态的。
这可以被重写以强制将非final类视为final。例如,如果应用程序广泛使用ArrayList,但从未使用ArrayList子类,则将ArrayList视为最终类可能会允许FieldSerializer为每个ArrayList字段节省1-2个字节。
代码示例来源:origin: EsotericSoftware/kryonet
if (kryo.isFinal(parameterTypes[ii])) cachedMethod.serializers[ii] = kryo.getSerializer(parameterTypes[ii]);
代码示例来源:origin: com.esotericsoftware/kryo
public void setGenerics (Kryo kryo, Class[] generics) {
genericType = null;
if (generics != null && generics.length > 0) {
if (kryo.isFinal(generics[0])) genericType = generics[0];
}
}
代码示例来源:origin: com.esotericsoftware/kryo
public void setGenerics (Kryo kryo, Class[] generics) {
keyGenericType = null;
valueGenericType = null;
if (generics != null && generics.length > 0) {
if (generics[0] != null && kryo.isFinal(generics[0])) keyGenericType = generics[0];
if (generics.length > 1 && generics[1] != null && kryo.isFinal(generics[1])) valueGenericType = generics[1];
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
public void setGenerics (Kryo kryo, Class[] generics) {
keyGenericType = null;
valueGenericType = null;
if (generics != null && generics.length > 0) {
if (generics[0] != null && kryo.isFinal(generics[0])) keyGenericType = generics[0];
if (generics.length > 1 && generics[1] != null && kryo.isFinal(generics[1])) valueGenericType = generics[1];
}
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void setGenerics (Kryo kryo, Class[] generics) {
keyGenericType = null;
valueGenericType = null;
if (generics != null && generics.length > 0) {
if (generics[0] != null && kryo.isFinal(generics[0])) keyGenericType = generics[0];
if (generics.length > 1 && generics[1] != null && kryo.isFinal(generics[1])) valueGenericType = generics[1];
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
public void setGenerics (Kryo kryo, Class[] generics) {
genericType = null;
if (generics != null && generics.length > 0) {
if (kryo.isFinal(generics[0])) genericType = generics[0];
}
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void setGenerics (Kryo kryo, Class[] generics) {
genericType = null;
if (generics != null && generics.length > 0) {
if (kryo.isFinal(generics[0])) genericType = generics[0];
}
}
代码示例来源:origin: svn2github/kryo
public void setGenerics (Kryo kryo, Class[] generics) {
keyGenericType = null;
valueGenericType = null;
if (generics != null && generics.length > 0) {
if (generics[0] != null && kryo.isFinal(generics[0])) keyGenericType = generics[0];
if (generics.length > 1 && generics[1] != null && kryo.isFinal(generics[1])) valueGenericType = generics[1];
}
}
代码示例来源:origin: svn2github/kryo
public void setGenerics (Kryo kryo, Class[] generics) {
genericType = null;
if (generics != null && generics.length > 0) {
if (kryo.isFinal(generics[0])) genericType = generics[0];
}
}
代码示例来源:origin: usc-cloud/goffish
@SuppressWarnings("rawtypes")
@Override
public void setGenerics(Kryo kryo, Class[] generics) {
_valueConcreteGenericType = null;
if (_valueConcreteType == null) {
// if we don't have a concrete class, see if generics can provide us with one
if (generics[0] != null && kryo.isFinal(generics[0])) {
_valueConcreteGenericType = generics[0];
}
}
}
代码示例来源:origin: com.esotericsoftware/kryonet
cachedMethod.serializers = new Serializer[parameterTypes.length];
for (int ii = 0, nn = parameterTypes.length; ii < nn; ii++)
if (kryo.isFinal(parameterTypes[ii])) cachedMethod.serializers[ii] = kryo.getSerializer(parameterTypes[ii]);
代码示例来源:origin: inspectIT/inspectIT
cachedMethod.serializers = new Serializer[parameterTypes.length];
for (int ii = 0, nn = parameterTypes.length; ii < nn; ii++) {
if (kryo.isFinal(parameterTypes[ii])) {
cachedMethod.serializers[ii] = kryo.getSerializer(parameterTypes[ii]);
代码示例来源:origin: com.esotericsoftware.kryo/kryo
CachedField newCachedField (Field field, int fieldIndex, int accessIndex) {
Class[] fieldClass = new Class[] {field.getType()};
Type fieldGenericType = field.getGenericType();
CachedField cachedField;
if (fieldGenericType == fieldClass[0]) {
// This is a field without generic type parameters
if (TRACE) trace("kryo", "Field " + field.getName() + ": " + fieldClass[0]);
cachedField = newMatchingCachedField(field, accessIndex, fieldClass[0], fieldGenericType, null);
} else {
cachedField = genericsUtil.newCachedFieldOfGenericType(field, accessIndex, fieldClass, fieldGenericType);
}
if (cachedField instanceof ObjectField) {
hasObjectFields = true;
}
cachedField.field = field;
cachedField.varIntsEnabled = varIntsEnabled;
if (!useAsmEnabled) {
cachedField.offset = unsafeUtil.getObjectFieldOffset(field);
}
cachedField.access = (FieldAccess)access;
cachedField.accessIndex = accessIndex;
cachedField.canBeNull = fieldsCanBeNull && !fieldClass[0].isPrimitive() && !field.isAnnotationPresent(NotNull.class);
// Always use the same serializer for this field if the field's class is final.
if (kryo.isFinal(fieldClass[0]) || fixedFieldTypes) cachedField.valueClass = fieldClass[0];
return cachedField;
}
代码示例来源:origin: svn2github/kryo
CachedField newCachedField (Field field, int fieldIndex, int accessIndex) {
Class[] fieldClass = new Class[] { field.getType() };
Type fieldGenericType = field.getGenericType();
CachedField cachedField;
if (fieldGenericType == fieldClass[0]) {
// This is a field without generic type parameters
if (TRACE) {
trace("kryo", "Field '" + field.getName() + "' of type " + fieldClass[0]);
}
cachedField = newMatchingCachedField(field, accessIndex, fieldClass[0], fieldGenericType, null);
} else {
cachedField = genericsUtil.newCachedFieldOfGenericType(field, accessIndex, fieldClass, fieldGenericType);
}
if (cachedField instanceof ObjectField) {
hasObjectFields = true;
}
cachedField.field = field;
cachedField.varIntsEnabled = varIntsEnabled;
if (!useAsmEnabled) {
cachedField.offset = unsafeUtil.getObjectFieldOffset(field);
}
cachedField.access = (FieldAccess)access;
cachedField.accessIndex = accessIndex;
cachedField.canBeNull = fieldsCanBeNull && !fieldClass[0].isPrimitive() && !field.isAnnotationPresent(NotNull.class);
// Always use the same serializer for this field if the field's class is final.
if (kryo.isFinal(fieldClass[0]) || fixedFieldTypes) cachedField.valueClass = fieldClass[0];
return cachedField;
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
if (kryo.isFinal(returnType)) serializer = kryo.getRegistration(returnType).getSerializer();
代码示例来源:origin: com.esotericsoftware/kryo
if (kryo.isFinal(returnType)) serializer = kryo.getRegistration(returnType).getSerializer();
代码示例来源:origin: com.esotericsoftware/kryo-shaded
if (kryo.isFinal(returnType)) serializer = kryo.getRegistration(returnType).getSerializer();
代码示例来源:origin: svn2github/kryo
if (kryo.isFinal(returnType)) serializer = kryo.getRegistration(returnType).getSerializer();
代码示例来源:origin: com.esotericsoftware/kryo
CachedField newCachedField (Field field, int fieldIndex, int accessIndex) {
Class[] fieldClass = new Class[] {field.getType()};
Type fieldGenericType = (config.isOptimizedGenerics()) ? field.getGenericType() : null;
CachedField cachedField;
if (!config.isOptimizedGenerics() || fieldGenericType == fieldClass[0]) {
// For optimized generics this is a field without generic type parameters
if (TRACE) trace("kryo", "Field " + field.getName() + ": " + fieldClass[0]);
cachedField = newMatchingCachedField(field, accessIndex, fieldClass[0], fieldGenericType, null);
} else {
cachedField = genericsUtil.newCachedFieldOfGenericType(field, accessIndex, fieldClass, fieldGenericType);
}
if (cachedField instanceof ObjectField) {
hasObjectFields = true;
}
cachedField.field = field;
cachedField.varIntsEnabled = varIntsEnabled;
if (!config.isUseAsm()) {
cachedField.offset = unsafeUtil.getObjectFieldOffset(field);
}
cachedField.access = (FieldAccess)access;
cachedField.accessIndex = accessIndex;
cachedField.canBeNull = config.isFieldsCanBeNull() && !fieldClass[0].isPrimitive()
&& !field.isAnnotationPresent(NotNull.class);
// Always use the same serializer for this field if the field's class is final.
if (kryo.isFinal(fieldClass[0]) || config.isFixedFieldTypes()) cachedField.valueClass = fieldClass[0];
return cachedField;
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
CachedField newCachedField (Field field, int fieldIndex, int accessIndex) {
Class[] fieldClass = new Class[] {field.getType()};
Type fieldGenericType = (config.isOptimizedGenerics()) ? field.getGenericType() : null;
CachedField cachedField;
if (!config.isOptimizedGenerics() || fieldGenericType == fieldClass[0]) {
// For optimized generics this is a field without generic type parameters
if (TRACE) trace("kryo", "Field " + field.getName() + ": " + fieldClass[0]);
cachedField = newMatchingCachedField(field, accessIndex, fieldClass[0], fieldGenericType, null);
} else {
cachedField = genericsUtil.newCachedFieldOfGenericType(field, accessIndex, fieldClass, fieldGenericType);
}
if (cachedField instanceof ObjectField) {
hasObjectFields = true;
}
cachedField.field = field;
cachedField.varIntsEnabled = varIntsEnabled;
if (!config.isUseAsm()) {
cachedField.offset = unsafeUtil.getObjectFieldOffset(field);
}
cachedField.access = (FieldAccess)access;
cachedField.accessIndex = accessIndex;
cachedField.canBeNull = config.isFieldsCanBeNull() && !fieldClass[0].isPrimitive()
&& !field.isAnnotationPresent(NotNull.class);
// Always use the same serializer for this field if the field's class is final.
if (kryo.isFinal(fieldClass[0]) || config.isFixedFieldTypes()) cachedField.valueClass = fieldClass[0];
return cachedField;
}
内容来源于网络,如有侵权,请联系作者删除!