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

io.logspace.agent.shaded.quartz.impl.matchers.NameMatcher Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
/*
 * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
 * 
 * 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 io.logspace.agent.shaded.quartz.impl.matchers;

import io.logspace.agent.shaded.quartz.JobKey;
import io.logspace.agent.shaded.quartz.TriggerKey;
import io.logspace.agent.shaded.quartz.utils.Key;

/**
 * Matches on name (ignores group) property of Keys.
 *  
 * @author jhouse
 */
public class NameMatcher> extends StringMatcher {
  
    private static final long serialVersionUID = -33104959459613480L;

    protected NameMatcher(String compareTo, StringOperatorName compareWith) {
        super(compareTo, compareWith);
    }
    
    /**
     * Create a NameMatcher that matches names equaling the given string.
     */
    public static > NameMatcher nameEquals(String compareTo) {
        return new NameMatcher(compareTo, StringOperatorName.EQUALS);
    }

    /**
     * Create a NameMatcher that matches job names equaling the given string.
     */
    public static NameMatcher jobNameEquals(String compareTo) {
        return NameMatcher.nameEquals(compareTo);
    }
    
    /**
     * Create a NameMatcher that matches trigger names equaling the given string.
     */
    public static NameMatcher triggerNameEquals(String compareTo) {
        return NameMatcher.nameEquals(compareTo);
    }
    
    /**
     * Create a NameMatcher that matches names starting with the given string.
     */
    public static > NameMatcher nameStartsWith(String compareTo) {
        return new NameMatcher(compareTo, StringOperatorName.STARTS_WITH);
    }

    /**
     * Create a NameMatcher that matches job names starting with the given string.
     */
    public static NameMatcher jobNameStartsWith(String compareTo) {
        return NameMatcher.nameStartsWith(compareTo);
    }
    
    /**
     * Create a NameMatcher that matches trigger names starting with the given string.
     */
    public static NameMatcher triggerNameStartsWith(String compareTo) {
        return NameMatcher.nameStartsWith(compareTo);
    }

    /**
     * Create a NameMatcher that matches names ending with the given string.
     */
    public static > NameMatcher nameEndsWith(String compareTo) {
        return new NameMatcher(compareTo, StringOperatorName.ENDS_WITH);
    }

    /**
     * Create a NameMatcher that matches job names ending with the given string.
     */
    public static NameMatcher jobNameEndsWith(String compareTo) {
        return NameMatcher.nameEndsWith(compareTo);
    }
    
    /**
     * Create a NameMatcher that matches trigger names ending with the given string.
     */
    public static NameMatcher triggerNameEndsWith(String compareTo) {
        return NameMatcher.nameEndsWith(compareTo);
    }

    /**
     * Create a NameMatcher that matches names containing the given string.
     */
    public static > NameMatcher nameContains(String compareTo) {
        return new NameMatcher(compareTo, StringOperatorName.CONTAINS);
    }

    /**
     * Create a NameMatcher that matches job names containing the given string.
     */
    public static NameMatcher jobNameContains(String compareTo) {
        return NameMatcher.nameContains(compareTo);
    }
    
    /**
     * Create a NameMatcher that matches trigger names containing the given string.
     */
    public static NameMatcher triggerNameContains(String compareTo) {
        return NameMatcher.nameContains(compareTo);
    }
    
    @Override
    protected String getValue(T key) {
        return key.getName();
    }

}