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

io.yawp.repository.shields.ShieldInfo Maven / Gradle / Ivy

There is a newer version: 2.08alpha
Show newest version
package io.yawp.repository.shields;

import io.yawp.repository.actions.ActionKey;
import io.yawp.repository.actions.InvalidActionMethodException;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ShieldInfo {

	private Class> shieldClazz;

	private Map actionMethods;

	public ShieldInfo(Class> shieldClazz) {
		this.shieldClazz = shieldClazz;
		parseActionMethods();
	}

	public Class> getShieldClazz() {
		return shieldClazz;
	}

	public Map getActionMethods() {
		return actionMethods;
	}

	private void parseActionMethods() {
		this.actionMethods = new HashMap();

		Method[] methods = shieldClazz.getDeclaredMethods();
		for (Method method : methods) {
			List actionKeys = parseActionKeys(method);

			for (ActionKey actionKey : actionKeys) {
				actionMethods.put(actionKey, method);
			}
		}
	}

	private List parseActionKeys(Method method) {
		try {
			return ActionKey.parseMethod(method);
		} catch (InvalidActionMethodException e) {
			throw new RuntimeException("Invalid action method in shield: " + shieldClazz.getName() + "." + method.getName(), e);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy