|
| 1 | +/* |
| 2 | + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. |
| 3 | + * |
| 4 | + * WSO2 Inc. licenses this file to you under the Apache License, |
| 5 | + * Version 2.0 (the "License"); you may not use this file except |
| 6 | + * in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, |
| 12 | + * software distributed under the License is distributed on an |
| 13 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | + * KIND, either express or implied. See the License for the |
| 15 | + * specific language governing permissions and limitations |
| 16 | + * under the License. |
| 17 | + */ |
| 18 | +package org.wso2.carbon.apimgt.impl.lifecycle; |
| 19 | +public class CheckListItem implements Comparable { |
| 20 | + private String lifeCycleStatus; |
| 21 | + private String name; |
| 22 | + private String value; |
| 23 | + private String order; |
| 24 | + private String propertyName; |
| 25 | + private String isVisible; |
| 26 | + private static final Object HASH_CODE_OBJECT = new Object(); |
| 27 | + |
| 28 | + public String getVisible() { |
| 29 | + return this.isVisible; |
| 30 | + } |
| 31 | + |
| 32 | + public void setVisible(String visible) { |
| 33 | + this.isVisible = visible; |
| 34 | + } |
| 35 | + |
| 36 | + public String getPropertyName() { |
| 37 | + return this.propertyName; |
| 38 | + } |
| 39 | + |
| 40 | + public void setPropertyName(String propertyName) { |
| 41 | + this.propertyName = propertyName; |
| 42 | + } |
| 43 | + |
| 44 | + public String getLifeCycleStatus() { |
| 45 | + return this.lifeCycleStatus; |
| 46 | + } |
| 47 | + |
| 48 | + public void setLifeCycleStatus(String lifeCycleStatus) { |
| 49 | + this.lifeCycleStatus = lifeCycleStatus; |
| 50 | + } |
| 51 | + |
| 52 | + public String getName() { |
| 53 | + return this.name; |
| 54 | + } |
| 55 | + |
| 56 | + public void setName(String name) { |
| 57 | + this.name = name; |
| 58 | + } |
| 59 | + |
| 60 | + public String getValue() { |
| 61 | + return this.value; |
| 62 | + } |
| 63 | + |
| 64 | + public void setValue(String value) { |
| 65 | + this.value = value; |
| 66 | + } |
| 67 | + |
| 68 | + public String getOrder() { |
| 69 | + return this.order; |
| 70 | + } |
| 71 | + |
| 72 | + public void setOrder(String order) { |
| 73 | + this.order = order; |
| 74 | + } |
| 75 | + |
| 76 | + public CheckListItem(String lifeCycleStatus, String name, String value, String order) { |
| 77 | + this.lifeCycleStatus = lifeCycleStatus; |
| 78 | + this.name = name; |
| 79 | + this.value = value; |
| 80 | + this.order = order; |
| 81 | + } |
| 82 | + |
| 83 | + public CheckListItem() { |
| 84 | + } |
| 85 | + |
| 86 | + public boolean matchLifeCycleStatus(String status, boolean ignoreCase) { |
| 87 | + if (this.lifeCycleStatus != null && status != null) { |
| 88 | + return ignoreCase ? this.lifeCycleStatus.equalsIgnoreCase(status) : this.lifeCycleStatus.equals(status); |
| 89 | + } else { |
| 90 | + return false; |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + public boolean matchLifeCycleStatus(String status) { |
| 95 | + return this.matchLifeCycleStatus(status, true); |
| 96 | + } |
| 97 | + |
| 98 | + public int hashCode() { |
| 99 | + int hashCode = HASH_CODE_OBJECT.hashCode(); |
| 100 | + if (this.order != null) { |
| 101 | + hashCode &= this.order.hashCode(); |
| 102 | + } |
| 103 | + |
| 104 | + if (this.name != null) { |
| 105 | + hashCode &= this.name.hashCode(); |
| 106 | + } |
| 107 | + |
| 108 | + if (this.value != null) { |
| 109 | + hashCode &= this.value.hashCode(); |
| 110 | + } |
| 111 | + |
| 112 | + if (this.lifeCycleStatus != null) { |
| 113 | + hashCode &= this.lifeCycleStatus.hashCode(); |
| 114 | + } |
| 115 | + |
| 116 | + if (this.propertyName != null) { |
| 117 | + hashCode &= this.propertyName.hashCode(); |
| 118 | + } |
| 119 | + |
| 120 | + return hashCode; |
| 121 | + } |
| 122 | + |
| 123 | + public boolean equals(Object obj) { |
| 124 | + if (!(obj instanceof CheckListItem)) { |
| 125 | + return false; |
| 126 | + } else { |
| 127 | + CheckListItem item = (CheckListItem)obj; |
| 128 | + return (this.order != null && this.order.equals(item.order) || this.order == null && item.order == null) && (this.lifeCycleStatus != null && this.lifeCycleStatus.equals(item.lifeCycleStatus) || this.lifeCycleStatus == null && item.lifeCycleStatus == null) && (this.name != null && this.name.equals(item.name) || this.name == null && item.name == null) && (this.value != null && this.value.equals(item.value) || this.value == null && item.value == null) && (this.propertyName != null && this.propertyName.equals(item.propertyName) || this.propertyName == null && item.propertyName == null); |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + public int compareTo(Object anotherItem) { |
| 133 | + if (this.equals(anotherItem)) { |
| 134 | + return 0; |
| 135 | + } else { |
| 136 | + CheckListItem item = (CheckListItem)anotherItem; |
| 137 | + int otherItemOrder = Integer.parseInt(item.getOrder()); |
| 138 | + int itemOrder = Integer.parseInt(this.order); |
| 139 | + return itemOrder - otherItemOrder; |
| 140 | + } |
| 141 | + } |
| 142 | +} |
0 commit comments