View Javadoc
1   /*
2    *    Copyright 2006-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.generator.config;
17  
18  import java.util.Arrays;
19  
20  /**
21   * This class holds constants useful in the XML and Java merging operations.
22   *
23   * @author Jeff Butler
24   */
25  public class MergeConstants {
26  
27      /**
28       * Utility class - no instances.
29       */
30      private MergeConstants() {
31      }
32  
33      private static final String[] OLD_XML_ELEMENT_PREFIXES = {
34              "ibatorgenerated_", "abatorgenerated_" }; //$NON-NLS-1$ //$NON-NLS-2$
35  
36      public static final String NEW_ELEMENT_TAG = "@mbg.generated"; //$NON-NLS-1$
37      private static final String[] OLD_ELEMENT_TAGS = {
38              "@ibatorgenerated", //$NON-NLS-1$
39              "@abatorgenerated", //$NON-NLS-1$
40              "@mbggenerated", //$NON-NLS-1$
41              NEW_ELEMENT_TAG };
42  
43      public static String[] getOldElementTags() {
44          return OLD_ELEMENT_TAGS;
45      }
46  
47      public static boolean idStartsWithPrefix(String id) {
48          return Arrays.stream(OLD_XML_ELEMENT_PREFIXES)
49                  .anyMatch(id::startsWith);
50      }
51  
52      public static boolean commentContainsTag(String comment) {
53          return Arrays.stream(OLD_ELEMENT_TAGS)
54                  .anyMatch(comment::contains);
55      }
56  }