com.infinities.keystone4j.policy.reducer.MakeNotExprReducer.java Source code

Java tutorial

Introduction

Here is the source code for com.infinities.keystone4j.policy.reducer.MakeNotExprReducer.java

Source

/*******************************************************************************
 * # Copyright 2015 InfinitiesSoft Solutions Inc.
 * #
 * # Licensed under the Apache License, Version 2.0 (the "License"); you may
 * # not use this file except in compliance with the License. You may obtain
 * # a copy of the License at
 * #
 * #      http://www.apache.org/licenses/LICENSE-2.0
 * #
 * # Unless required by applicable law or agreed to in writing, software
 * # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * # License for the specific language governing permissions and limitations
 * # under the License.
 *******************************************************************************/
package com.infinities.keystone4j.policy.reducer;

import java.util.List;
import java.util.Map.Entry;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.infinities.keystone4j.policy.BaseReducer;
import com.infinities.keystone4j.policy.check.BaseCheck;
import com.infinities.keystone4j.policy.check.NotCheck;

public class MakeNotExprReducer extends AbstractReducer {

    private final static List<List<String>> reducers = Lists.newArrayList();
    static {
        List<String> reducer1 = Lists.newArrayList();
        reducer1.add("not");
        reducer1.add("check");
        reducers.add(reducer1);
    }

    public MakeNotExprReducer(BaseReducer reducer) {
        super(reducer);
    }

    @Override
    public List<List<String>> getReducers() {
        return reducers;
    }

    @Override
    public Entry<String, BaseCheck> getEntry(List<Entry<String, BaseCheck>> entry) {
        BaseCheck notCheck = new NotCheck(entry.get(1).getValue());
        return Maps.immutableEntry("check", notCheck);
    }
}