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

run.halo.app.extension.index.AbstractIndexAttribute Maven / Gradle / Ivy

The newest version!
package run.halo.app.extension.index;

import lombok.EqualsAndHashCode;
import org.springframework.util.Assert;
import run.halo.app.extension.Extension;
import run.halo.app.extension.GVK;

@EqualsAndHashCode
public abstract class AbstractIndexAttribute implements IndexAttribute {
    private final Class objectType;

    /**
     * Creates a new {@link AbstractIndexAttribute} for the given object type.
     *
     * @param objectType must not be {@literal null}.
     */
    public AbstractIndexAttribute(Class objectType) {
        Assert.notNull(objectType, "Object type must not be null");
        Assert.state(isValidExtension(objectType),
            "Invalid extension type, make sure you have annotated it with @" + GVK.class
                .getSimpleName());
        this.objectType = objectType;
    }

    @Override
    public Class getObjectType() {
        return this.objectType;
    }

    boolean isValidExtension(Class type) {
        return type.getAnnotation(GVK.class) != null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy