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

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

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

import jakarta.servlet.http.HttpServletRequest;

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

/**
 * Abstract language guard.
 * 
 * @author Alexandr Bolbat
 */
public abstract class LanguageAbstractGuard implements ConditionalGuard {

	/**
	 * Target language.
	 * 
	 * @return {@link String} language code (configured code from ano-site definition)
	 */
	protected abstract String getTargetLanguage();

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

	@Override
	public final boolean isConditionFullfilled(final DataObject object, final HttpServletRequest req) {
		return ContextManager.getCallContext().getCurrentLanguage().equals(getTargetLanguage()) == shouldMatch();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy