View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
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    *     http://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 de.smartics.properties.resource.maven.repository;
17  
18  import de.smartics.exceptions.code.NumberCodeInfo;
19  import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
20  import de.smartics.properties.resource.app.ResourcesCode;
21  
22  /**
23   * Codes dealing with resource problems accessing with Maven.
24   */
25  public enum MavenResourceCode implements ResourcesCode
26  {
27    // ***************************** Enumeration ******************************
28  
29    /**
30     * The target folder cannot be cleaned.
31     */
32    @MessageParamsDescriptor(ArtifactIdMessageBean.class)
33    ARTIFACT_RESOLVING_FAILED(0),
34  
35    /**
36     * The Maven settings file cannot be found.
37     */
38    @MessageParamsDescriptor(FileMessageBean.class)
39    CANNOT_FIND_SETTINGS(10),
40  
41    /**
42     * The Maven settings file cannot be read.
43     */
44    @MessageParamsDescriptor(FileMessageBean.class)
45    CANNOT_READ_SETTINGS(11);
46  
47    // ******************************** Fields ********************************
48  
49    // --- constants ----------------------------------------------------------
50  
51    // --- members ------------------------------------------------------------
52  
53    /**
54     * The code information.
55     */
56    private final NumberCodeInfo info;
57  
58    // ***************************** Constructors *****************************
59  
60    /**
61     * Default constructor.
62     *
63     * @param minorNumber the minor part of the error code.
64     */
65    private MavenResourceCode(final Integer minorNumber)
66    {
67      final int start = 6000;
68      this.info = new NumberCodeInfo("ResourceMaven", start, minorNumber);
69    }
70  
71    // ******************************** Methods *******************************
72  
73    // --- init ---------------------------------------------------------------
74  
75    // --- get&set ------------------------------------------------------------
76  
77    @Override
78    public String getCode()
79    {
80      return info.getCode();
81    }
82  
83    @Override
84    public String getComponentId()
85    {
86      return info.getComponentId();
87    }
88  
89    @Override
90    public String getDisplayId()
91    {
92      return info.toString();
93    }
94  
95    @Override
96    public Integer getMajorNumber()
97    {
98      return info.getMajorNumber();
99    }
100 
101   @Override
102   public Integer getMinorNumber()
103   {
104     return info.getMinorNumber();
105   }
106 
107   // --- business -----------------------------------------------------------
108 
109   // --- object basics ------------------------------------------------------
110 
111   /**
112    * Returns the string representation of the object.
113    *
114    * @return the string representation of the object.
115    */
116   @Override
117   public String toString()
118   {
119     return getDisplayId();
120   }
121 }