class AllowedOperation {

    public boolean isOperationAllowedOn(String opItemType, String opItemValue, MatchType matchType) {
        
        // if no operationItems are defined, always allow all 
        if (this.items == null || this.items.isEmpty()) {
            return true;
        }
        
        // if there are operations defined, and opItemType or opItemValue are empty, return false
        if (opItemType == null || opItemValue == null) {
            return false;
        }
        
        // if not empty, check and make sure the opItem type + value is found.
        opItemType = opItemType.toLowerCase();
        opItemValue = opItemValue.toLowerCase();
        Set<String> opItems = this.items.get(opItemType);
        if (opItems == null) {
            return false;
        }

        boolean result = false;
        switch (matchType) {
            case EQUALS:
                result = opItems.contains(opItemValue);
                break;
            case STARTS_WITH:
                for (String value : opItems) {
                    if (opItemValue.startsWith(value)) {
                        result = true;
                        break;
                    }
                }
                break;
        }
        return result;
    }

}