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

com.speedment.codegen.model.AnnotationUsage Maven / Gradle / Ivy

Go to download

An object-oriented code generator for Java that is built using the Model-View-Controller (MVC) design philosophy.

There is a newer version: 2.4.5
Show newest version
/**
 *
 * Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.codegen.model;

import com.speedment.annotation.Api;
import com.speedment.codegen.model.trait.HasCopy;
import com.speedment.codegen.model.trait.HasType;
import com.speedment.codegen.model.trait.HasValue;
import com.speedment.internal.codegen.model.AnnotationUsageImpl;
import java.util.List;
import java.util.Map;
import static java.util.Objects.requireNonNull;
import java.util.function.Function;

/**
 * A model that represents the usage of a particular annotation in code.
 *
 * @author Emil Forslund
 * @see Annotation
 * @since   2.0
 */
@Api(version = "2.3")
public interface AnnotationUsage extends HasCopy,
    HasType, HasValue {

    /**
     * Use the specified key-value pair when referencing the annotation. If you
     * only want to show a single value without any key, consider using the
     * {@link #put(String, Value)} method.
     *
     * @param key the key
     * @param val the value
     * @return a reference to this model
     */
    AnnotationUsage put(String key, Value val);

    /**
     * Returns a list of all the key-value pairs in this model.
     *
     * @return all key-value pairs
     */
    List>> getValues();

    /**
     * Factory holder.
     */
    enum Factory {
        INST;
        private Function mapper = AnnotationUsageImpl::new;
    }

    /**
     * Creates a new instance implementing this interface by using the class
     * supplied by the default factory. To change implementation, please use the
     * {@link #setSupplier(java.util.function.Function) setSupplier} method.
     *
     * @param type the type
     * @return the new instance
     */
    static AnnotationUsage of(Type type) {
        return Factory.INST.mapper.apply(type);
    }

    /**
     * Sets the instantiation method used to create new instances of this
     * interface.
     *
     * @param mapper the new constructor
     */
    static void setSupplier(Function mapper) {
        Factory.INST.mapper = requireNonNull(mapper);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy