-
Notifications
You must be signed in to change notification settings - Fork 100
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
1 parent
15c1d94
commit fa6dea0
Showing
52 changed files
with
2,710 additions
and
2,659 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
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
45 changes: 45 additions & 0 deletions
45
thrifty-java-codegen/src/main/java/com/microsoft/thrifty/gen/FieldNamer.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,45 @@ | ||
/* | ||
* Thrifty | ||
* | ||
* Copyright (c) Microsoft Corporation | ||
* | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the License); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING | ||
* WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, | ||
* FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. | ||
* | ||
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.microsoft.thrifty.gen; | ||
|
||
import com.microsoft.thrifty.schema.Field; | ||
import com.microsoft.thrifty.schema.FieldNamingPolicy; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
class FieldNamer { | ||
private final Map<Field, String> nameCache = new LinkedHashMap<>(); | ||
private final FieldNamingPolicy namingPolicy; | ||
|
||
FieldNamer(FieldNamingPolicy namingPolicy) { | ||
this.namingPolicy = namingPolicy; | ||
} | ||
|
||
public String getName(Field field) { | ||
String name = nameCache.get(field); | ||
if (name == null) { | ||
name = namingPolicy.apply(field.name()); | ||
nameCache.put(field, name); | ||
} | ||
return name; | ||
} | ||
} |
Oops, something went wrong.