Search in sources :

Example 1 with ProtoName

use of org.infinispan.protostream.annotations.ProtoName in project protostream by infinispan.

the class ProtoEnumTypeMetadata method getProtoName.

private static String getProtoName(XClass annotatedEnumClass, XClass enumClass) {
    ProtoName annotation = annotatedEnumClass.getAnnotation(ProtoName.class);
    ProtoEnum protoEnumAnnotation = annotatedEnumClass.getAnnotation(ProtoEnum.class);
    if (annotation != null) {
        if (protoEnumAnnotation != null) {
            throw new ProtoSchemaBuilderException("@ProtoEnum annotation cannot be used together with @ProtoName: " + annotatedEnumClass.getName());
        }
        return annotation.value().isEmpty() ? enumClass.getSimpleName() : annotation.value();
    }
    return protoEnumAnnotation == null || protoEnumAnnotation.name().isEmpty() ? enumClass.getSimpleName() : protoEnumAnnotation.name();
}
Also used : ProtoEnum(org.infinispan.protostream.annotations.ProtoEnum) ProtoSchemaBuilderException(org.infinispan.protostream.annotations.ProtoSchemaBuilderException) ProtoName(org.infinispan.protostream.annotations.ProtoName)

Example 2 with ProtoName

use of org.infinispan.protostream.annotations.ProtoName in project protostream by infinispan.

the class ProtoMessageTypeMetadata method getProtoName.

private static String getProtoName(XClass annotatedClass, XClass javaClass) {
    ProtoName annotation = annotatedClass.getAnnotation(ProtoName.class);
    ProtoMessage protoMessageAnnotation = annotatedClass.getAnnotation(ProtoMessage.class);
    if (annotation != null) {
        if (protoMessageAnnotation != null) {
            throw new ProtoSchemaBuilderException("@ProtoMessage annotation cannot be used together with @ProtoName: " + annotatedClass.getName());
        }
        return annotation.value().isEmpty() ? javaClass.getSimpleName() : annotation.value();
    }
    return protoMessageAnnotation == null || protoMessageAnnotation.name().isEmpty() ? javaClass.getSimpleName() : protoMessageAnnotation.name();
}
Also used : ProtoSchemaBuilderException(org.infinispan.protostream.annotations.ProtoSchemaBuilderException) ProtoMessage(org.infinispan.protostream.annotations.ProtoMessage) ProtoName(org.infinispan.protostream.annotations.ProtoName)

Aggregations

ProtoName (org.infinispan.protostream.annotations.ProtoName)2 ProtoSchemaBuilderException (org.infinispan.protostream.annotations.ProtoSchemaBuilderException)2 ProtoEnum (org.infinispan.protostream.annotations.ProtoEnum)1 ProtoMessage (org.infinispan.protostream.annotations.ProtoMessage)1