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

net.anotheria.anosite.guard.BrandAbstractGuard Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
package net.anotheria.anosite.guard;

import net.anotheria.anodoc.util.context.ContextManager;
import net.anotheria.asg.data.DataObject;
import net.anotheria.asg.exception.ASGRuntimeException;

import jakarta.servlet.http.HttpServletRequest;

/**
 * Abstract brand guard.
 *
 * @author ykalapusha
 */
public abstract class BrandAbstractGuard implements ConditionalGuard {
    /**
     * Target brand.
     *
     * @return {@link String} brand target name
     */
    protected abstract String getTargetBrand();

    /**
     * By overriding this method we can change conditional logic.
     *
     * @return {@code true} if target brand should be equal to current logic or {@code false} if shouldn't
     */
    protected boolean shouldMatch() {
        return true;
    }

    @Override
    public boolean isConditionFullfilled(DataObject object, HttpServletRequest req) throws ASGRuntimeException {
        return shouldMatch() == getTargetBrand().equals(ContextManager.getCallContext().getBrandConfig().getName());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy