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() {
41 protected void id(String id) {
45 public String message() {
50 protected void message(String message) {
51 this.message = message;
54 public ErrorCategory category() {
59 protected void category(ErrorCategory category) {
60 this.category = category;
64 public String toString() {
68 public static class ErrorCodeBuilder {
71 private String message;
72 private ErrorCategory category = ErrorCategory.APPLICATION;
74 public ErrorCodeBuilder withId(String id) {
81 public ErrorCodeBuilder withMessage(String message) {
82 this.message = message;
87 public ErrorCodeBuilder withCategory(ErrorCategory category) {
88 this.category = category;
95 * @return the error code
97 public ErrorCode build() {
98 ErrorCode inst = new ErrorCode();
100 inst.message = message;
101 inst.category = category;