001/*
002 * Copyright 1999-2018 Alibaba Group Holding Ltd.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package io.jboot.support.sentinel;
017
018import java.lang.reflect.Method;
019
020/**
021 * @author Eric Zhao
022 */
023class MethodWrapper {
024
025    private final Method method;
026    private final boolean present;
027
028    private MethodWrapper(Method method, boolean present) {
029        this.method = method;
030        this.present = present;
031    }
032
033    static MethodWrapper wrap(Method method) {
034        if (method == null) {
035            return none();
036        }
037        return new MethodWrapper(method, true);
038    }
039
040    static MethodWrapper none() {
041        return new MethodWrapper(null, false);
042    }
043
044    Method getMethod() {
045        return method;
046    }
047
048    boolean isPresent() {
049        return present;
050    }
051}