This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement restrictive deserialization
Following the API guidelines, we're implementing a restrictive deserialization strategy https://opensource.zalando.com/restful-api-guidelines/#109
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
package org.zalando.nakadi.domain; | ||
|
||
public enum Audience { | ||
COMPONENT_INTERNAL, BUSINESS_UNIT_INTERNAL, COMPANY_INTERNAL, EXTERNAL_PARTNER, EXTERNAL_PUBLIC | ||
COMPONENT_INTERNAL("component-internal"), | ||
BUSINESS_UNIT_INTERNAL("business-unit-internal"), | ||
COMPANY_INTERNAL("company-internal"), | ||
EXTERNAL_PARTNER("external-partner"), | ||
EXTERNAL_PUBLIC("external-public"); | ||
|
||
private String text; | ||
|
||
Audience(final String text) { | ||
this.text = text; | ||
} | ||
|
||
public String getText() { | ||
return this.text; | ||
} | ||
|
||
public static Audience fromString(final String text) { | ||
for (final Audience audience : Audience.values()) { | ||
if (audience.text.equals(text)) { | ||
return audience; | ||
} | ||
} | ||
throw new IllegalArgumentException(); | ||
} | ||
} |