001/* 002 * Copyright (c) 2022-2025, Mybatis-Flex (fuhai999@gmail.com). 003 * <p> 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 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 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 com.mybatisflex.core.datasource; 017 018import com.mybatisflex.core.util.StringUtil; 019 020public enum DataSourceProperty { 021 022 URL("url", new String[]{"url", "jdbcUrl"}), 023 USERNAME("username", new String[]{"username"}), 024 PASSWORD("password", new String[]{"password"}), 025 ; 026 027 String property; 028 String[] methodFlags; 029 030 DataSourceProperty(String property, String[] methodFlags) { 031 this.property = property; 032 this.methodFlags = methodFlags; 033 } 034 035 String[] getGetterMethods() { 036 String[] getterMethods = new String[methodFlags.length]; 037 for (int i = 0; i < methodFlags.length; i++) { 038 getterMethods[i] = "get" + StringUtil.firstCharToUpperCase(methodFlags[i]); 039 } 040 return getterMethods; 041 } 042 043 String[] getSetterMethods() { 044 String[] getterMethods = new String[methodFlags.length]; 045 for (int i = 0; i < methodFlags.length; i++) { 046 getterMethods[i] = "set" + StringUtil.firstCharToUpperCase(methodFlags[i]); 047 } 048 return getterMethods; 049 } 050}