2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.common.errors;
23 import java.io.Serializable;
25 public class ErrorCode implements Serializable {
27 private static final long serialVersionUID = 1L;
30 private String message;
31 private ErrorCategory category;
33 protected ErrorCode() {
36 For backward compatibility only - will be removed soon
40 public String toString() {
49 protected void id(String id) {
53 public String message() {
58 protected void message(String message) {
59 this.message = message;
62 public ErrorCategory category() {
67 protected void category(ErrorCategory category) {
68 this.category = category;
71 public static class ErrorCodeBuilder {
74 private String message;
75 private ErrorCategory category = ErrorCategory.APPLICATION;
77 public ErrorCodeBuilder withId(String id) {
84 public ErrorCodeBuilder withMessage(String message) {
85 this.message = message;
90 public ErrorCodeBuilder withCategory(ErrorCategory category) {
91 this.category = category;
98 * @return the error code
100 public ErrorCode build() {
101 ErrorCode inst = new ErrorCode();
103 inst.message = message;
104 inst.category = category;