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

org.sdmlib.models.classes.FeatureProperty Maven / Gradle / Ivy

Go to download

SDMLib is a light weight modeling library. SDMLib intentionally comes without any tool or editor.

There is a newer version: 2.3.2341
Show newest version
package org.sdmlib.models.classes;

import java.util.HashSet;

import de.uniks.networkparser.graph.Clazz;

public class FeatureProperty {
	public static final Clazz ALL = new Clazz().with("*");
	private HashSet includeClazz = new HashSet();
	private HashSet excludeClazz = new HashSet();
	private HashSet path = new HashSet();
	
	public FeatureProperty(){
		includeClazz.add(ALL);
	}
	
	public boolean match(String clazzName){
		// if Clazz is positive
		boolean result=false;
		for(Clazz item : includeClazz) {
			if(item == null) {
				continue;
			}
			if(ALL.getName(false).equals(item.getName(false))) {
				result = true;
				break;
			} else if(item.getName(false).equals(clazzName)) {
				result = true;
				break;
			}
		}
		
		for(Clazz item : excludeClazz) {
			if(item == null) {
				continue;
			}
			if(ALL.getName(false).equals(item.getName(false))) {
				result = false;
				break;
			} else if(item.getName(false).equals(clazzName)) {
				result = false;
				break;
			}
		}
		return result;
	}

	public FeatureProperty withPath(String... value) {
		if(value == null) {
			return this;
		}
		for(String item : value) {
			if(item != null) {
				path.add(item);
			}
		}
		return this;
	}

	public FeatureProperty withInclude(String... value) {
		if(value == null) {
			return this;
		}
		for(String item : value) {
			if(item != null) {
				excludeClazz.add(new Clazz().with(item));
			}
		}
		
		return this;
	}

	public FeatureProperty withExclude(String... value) {
		if(value == null) {
			return this;
		}
		if(value.length > 0 ){
			// remove ALL
			includeClazz.remove(ALL);
		}
		for(String item : value) {
			if(item != null) {
				includeClazz.add(new Clazz().with(item));
			}
		}
		
		return this;
	}
	
	public FeatureProperty withExclude(Clazz... value) {
		if(value == null) {
			return this;
		}
		if(value.length > 0 ){
			// remove ALL
			includeClazz.remove(ALL);
		}
		for(Clazz item : value) {
			if(item != null) {
				includeClazz.add(item);
			}
		}
		
		return this;
	}

	public HashSet getPath() {
		return path;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy