-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
4,093 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
55 changes: 55 additions & 0 deletions
55
...in/java/com/amazonaws/util/awsclientsmithygenerator/generators/SmithyC2JNamespaceMap.java
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.amazonaws.util.awsclientsmithygenerator.generators; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.Map; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
public class SmithyC2JNamespaceMap { | ||
private static SmithyC2JNamespaceMap instance = null; | ||
private static Map<String, String> SMITHY_C2J_SERVICE_NAME_MAP; | ||
private static boolean isInitialized = false; | ||
|
||
|
||
private SmithyC2JNamespaceMap(String jsonString){ | ||
|
||
Type mapType = new TypeToken<Map<String, String>>(){}.getType(); | ||
Gson gson = new Gson(); | ||
SMITHY_C2J_SERVICE_NAME_MAP = gson.fromJson(jsonString, mapType); | ||
} | ||
|
||
//This method must be called once to construct an internal mapping of smithy to c2j namespace | ||
public static SmithyC2JNamespaceMap getInstance(String jsonString) | ||
{ | ||
//double check locking | ||
if(instance == null) | ||
{ | ||
synchronized (SmithyC2JNamespaceMap.class) { | ||
if (instance == null) { | ||
instance = new SmithyC2JNamespaceMap(jsonString); | ||
isInitialized = true; | ||
} | ||
} | ||
} | ||
return instance; | ||
} | ||
|
||
public static SmithyC2JNamespaceMap getInstance() | ||
{ | ||
if (!isInitialized) { | ||
// If accessed without prior initialization, throw an exception | ||
throw new IllegalStateException("Singleton not initialized. Call getInstance(json string) first."); | ||
} | ||
return instance; | ||
} | ||
|
||
public static String getC2JServiceName(String smithyServiceName) | ||
{ | ||
if(SMITHY_C2J_SERVICE_NAME_MAP.containsKey(smithyServiceName)) | ||
{ | ||
return SMITHY_C2J_SERVICE_NAME_MAP.get(smithyServiceName); | ||
} | ||
return smithyServiceName; | ||
} | ||
} |
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
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
Oops, something went wrong.