View Javadoc
1   package io.github.magwas.inez.element;
2   
3   import java.util.List;
4   
5   import org.springframework.beans.factory.annotation.Autowired;
6   import org.springframework.stereotype.Service;
7   
8   @Service
9   public class IsInstanceService implements ElementConstants {
10  
11  	@Autowired
12  	GetRelativeForBridiElementService getRelativeForBridiElement;
13  
14  	public boolean apply(String objectId, String typeId) {
15  		if (THING_ID.equals(typeId))
16  			return true;
17  		List<String> relatives = getRelativeForBridiElement
18  				.apply(objectId, IS_A_ID, 1, 2).distinct().toList();
19  		if (relatives.contains(typeId))
20  			return true;
21  		for (String relative : relatives) {
22  			if (!relative.equals(THING_ID))
23  				if (apply(relative, typeId))
24  					return true;
25  		}
26  		return false;
27  	}
28  
29  }