All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.smallrye.graphql.schema.helper.DefaultValueHelper Maven / Gradle / Ivy

The newest version!
package io.smallrye.graphql.schema.helper;

import java.util.Optional;

import io.smallrye.graphql.schema.Annotations;

/**
 * Helping to figure out if there is a default value.
 * Looking for the @DefaultValue annotation.
 *
 * @author Phillip Kruger ([email protected])
 */
public class DefaultValueHelper {

    /**
     * Find a default object in the annotation, or empty if nothing
     *
     * @param annotations the annotations to search in
     * @return a optional default object
     */
    public static Optional getDefaultValue(Annotations... annotations) {
        for (Annotations a : annotations) {
            if (a.containsKeyAndValidValue(Annotations.DEFAULT_VALUE)) {
                return Optional.of(a.getAnnotationValue(Annotations.DEFAULT_VALUE).value().toString());
            }
        }
        return Optional.empty();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy