Java源码示例:io.siddhi.annotation.Parameter
示例1
private static String getSupportedParamOverloads(Map<String, Parameter> parameterMap,
ParameterOverload[] parameterOverloads) {
StringJoiner stringJoiner = new StringJoiner(", ");
for (ParameterOverload parameterOverload : parameterOverloads) {
String[] parameterNames = parameterOverload.parameterNames();
if (parameterNames.length != 0) {
StringJoiner paramOverloadStringJoiner = new StringJoiner(", ", "(", ")");
for (int i = 0; i < parameterNames.length; i++) {
StringBuilder stringBuilder = new StringBuilder();
if (!SiddhiConstants.REPETITIVE_PARAMETER_NOTATION.equals(parameterNames[i])) {
stringBuilder.append(getFormattedStringForDataType(parameterMap.
get(parameterNames[i]).type()));
stringBuilder.append(" ").append(parameterNames[i]);
} else {
stringBuilder.append(getFormattedStringForDataType(parameterMap.
get(parameterNames[i - 1]).type()));
stringBuilder.append(" ").append(SiddhiConstants.REPETITIVE_PARAMETER_NOTATION);
}
paramOverloadStringJoiner.add(stringBuilder);
}
stringJoiner.add(paramOverloadStringJoiner.toString());
}
}
return stringJoiner.toString();
}
示例2
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
}
}
示例3
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例4
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例5
@Override
public synchronized void init(ProcessingEnvironment env) {
super.init(env);
messager = env.getMessager();
// Populating the supported annotations class.
annotationsClasses.add(Extension.class);
annotationsClasses.add(Parameter.class);
annotationsClasses.add(ParameterOverload.class);
annotationsClasses.add(ReturnAttribute.class);
annotationsClasses.add(SystemParameter.class);
annotationsClasses.add(Example.class);
}
示例6
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
}
}
示例7
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例8
/**
* This method uses for validate @Extension / @Parameter element.
*
* @param parameters parameter array which needs to be validate.
* @throws AnnotationValidationException whenever if the validate rule violate, throws the annotation validate
* exception with proper message.
*/
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name {0} annotated in class {1} is not in proper format 'abc.def.ghi'.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例9
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!(PARAMETER_NAME_PATTERN.matcher(parameterName).find() ||
REPETITIVE_PARAMETER_NOTATION.equals(parameterName))) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例10
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
if (parameters != null && parameters.length > 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"cannot be annotated in class {0}. As this class extends from super class {1}.",
extensionClassFullName, AnnotationConstants.DISTRIBUTION_STRATEGY_SUPER_CLASS));
}
}
示例11
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!PARAMETER_NAME_PATTERN.matcher(parameterName).find()) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter dynamic property false or empty in the classes extending
//super classes except the Sink & SinkMapper.
if (parameter.dynamic()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> dynamic property cannot be annotated true in class {1}.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例12
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!PARAMETER_NAME_PATTERN.matcher(parameterName).find()) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter dynamic property false or empty in the classes extending
//super classes except the Sink & SinkMapper.
if (parameter.dynamic()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> dynamic property cannot be annotated true in class {1}.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}
示例13
@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {
for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
if (parameterName.isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"-> name annotated in class {0} is null or empty.", extensionClassFullName));
} else if (!PARAMETER_NAME_PATTERN.matcher(parameterName).find()) {
//Check if the @Parameter name is in a correct format 'abc.def.ghi' using regex pattern.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} annotated in class {1} is not in proper format ''abc.def.ghi''.",
parameterName, extensionClassFullName));
}
//Check if the @Parameter description is empty.
if (parameter.description().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> description annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter type is empty.
if (parameter.type().length == 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> type annotated in class {1} is null or empty.", parameterName,
extensionClassFullName));
}
//Check if the @Parameter dynamic property false or empty in the classes extending
//super classes except the Sink & SinkMapper.
if (parameter.dynamic()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter ->" +
" name:{0} -> dynamic property cannot be annotated true in class {1}.", parameterName,
extensionClassFullName));
}
if (parameter.optional()) {
if (parameter.defaultValue().isEmpty()) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter -> " +
"name:{0} -> defaultValue annotated in class {1} cannot be null or empty for the " +
"optional parameter.", parameterName, extensionClassFullName));
}
}
}
}