Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

package org.apache.cloudstack.storage.feign.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.List;

/**
Expand Down Expand Up @@ -54,6 +56,7 @@ public enum ProtocolsEnum {
this.value = value;
}

@JsonValue
public String getValue() {
return value;
}
Expand All @@ -63,9 +66,11 @@ public String toString() {
return String.valueOf(value);
}

@JsonCreator
public static ProtocolsEnum fromValue(String text) {
if (text == null) return null;
for (ProtocolsEnum b : ProtocolsEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equalsIgnoreCase(text)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause NPE if b.value is null.
Add null check for b.value or add a opposite condition like text.equalsIgnoreCase(b.value)

return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

package org.apache.cloudstack.storage.feign.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -71,6 +73,7 @@ public enum OsTypeEnum {
this.value = value;
}

@JsonValue
public String getValue() {
return value;
}
Expand All @@ -80,9 +83,11 @@ public String toString() {
return String.valueOf(value);
}

@JsonCreator
public static OsTypeEnum fromValue(String text) {
if (text == null) return null;
for (OsTypeEnum b : OsTypeEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equalsIgnoreCase(text)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause NPE if b.value is null.
Add null check for b.value or add a opposite condition like text.equalsIgnoreCase(b.value)

return b;
}
}
Expand Down Expand Up @@ -122,6 +127,7 @@ public enum ProtocolEnum {
this.value = value;
}

@JsonValue
public String getValue() {
return value;
}
Expand All @@ -131,9 +137,11 @@ public String toString() {
return String.valueOf(value);
}

@JsonCreator
public static ProtocolEnum fromValue(String text) {
if (text == null) return null;
for (ProtocolEnum b : ProtocolEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equalsIgnoreCase(text)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

return b;
}
}
Expand Down
Loading