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

br.com.caelum.brutauth.reflection.methodsearchers.MatchedParameters Maven / Gradle / Ivy

There is a newer version: 4.0.4
Show newest version
package br.com.caelum.brutauth.reflection.methodsearchers;

import java.util.HashMap;
import java.util.Map;

import br.com.caelum.brutauth.reflection.Argument;
import br.com.caelum.brutauth.reflection.MatchLevel;
import br.com.caelum.brutauth.reflection.Parameter;

public class MatchedParameters {
	private final Map matches = new HashMap<>();

	public void tryToPut(Parameter param, Argument arg) {
		MatchLevel matchLevel = arg.matches(param);
		
		if(MatchLevel.ZERO.equals(matchLevel)) return;
		
		MatchedArgument matchedArgument = matches.get(param);
		boolean hasAFullMatch = matchedArgument != null && matchedArgument.isFull();
		if(hasAFullMatch) return;

		matches.put(param, new MatchedArgument(arg, matchLevel));
	}
	
	public MatchedArgument get(Parameter parameter) {
		return matches.get(parameter);
	}

	public boolean alreadyMatchedBy(Argument arg) {
		return matches.containsValue(new MatchedArgument(arg, null));
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy