-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from turkraft/3.x.x
Left join singular attributes and example fixes
- Loading branch information
Showing
13 changed files
with
130 additions
and
9 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
37 changes: 37 additions & 0 deletions
37
...example/src/main/java/com/turkraft/springfilter/example/StringToEnumConverterFactory.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,37 @@ | ||
package com.turkraft.springfilter.example; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.core.convert.converter.ConverterFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StringToEnumConverterFactory | ||
implements ConverterFactory<String, Enum> { | ||
|
||
private static class StringToEnumConverter<T extends Enum> | ||
implements Converter<String, T> { | ||
|
||
private final Class<T> enumType; | ||
|
||
public StringToEnumConverter(Class<T> enumType) { | ||
this.enumType = enumType; | ||
} | ||
|
||
public T convert(String source) { | ||
for (T constant : enumType.getEnumConstants()) { | ||
if (constant.toString().equalsIgnoreCase(source)) { | ||
return constant; | ||
} | ||
} | ||
return (T) Enum.valueOf(this.enumType, source.trim()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public <T extends Enum> Converter<String, T> getConverter( | ||
Class<T> targetType) { | ||
return new StringToEnumConverter(targetType); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
jpa-example/src/main/java/com/turkraft/springfilter/example/WebConfiguration.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,15 @@ | ||
package com.turkraft.springfilter.example; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.format.FormatterRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfiguration implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addFormatters(FormatterRegistry registry) { | ||
registry.addConverterFactory(new StringToEnumConverterFactory()); | ||
} | ||
|
||
} |
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
37 changes: 37 additions & 0 deletions
37
...example/src/main/java/com/turkraft/springfilter/example/StringToEnumConverterFactory.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,37 @@ | ||
package com.turkraft.springfilter.example; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.core.convert.converter.ConverterFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StringToEnumConverterFactory | ||
implements ConverterFactory<String, Enum> { | ||
|
||
private static class StringToEnumConverter<T extends Enum> | ||
implements Converter<String, T> { | ||
|
||
private final Class<T> enumType; | ||
|
||
public StringToEnumConverter(Class<T> enumType) { | ||
this.enumType = enumType; | ||
} | ||
|
||
public T convert(String source) { | ||
for (T constant : enumType.getEnumConstants()) { | ||
if (constant.toString().equalsIgnoreCase(source)) { | ||
return constant; | ||
} | ||
} | ||
return (T) Enum.valueOf(this.enumType, source.trim()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public <T extends Enum> Converter<String, T> getConverter( | ||
Class<T> targetType) { | ||
return new StringToEnumConverter(targetType); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
mongo-example/src/main/java/com/turkraft/springfilter/example/WebConfiguration.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,15 @@ | ||
package com.turkraft.springfilter.example; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.format.FormatterRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfiguration implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addFormatters(FormatterRegistry registry) { | ||
registry.addConverterFactory(new StringToEnumConverterFactory()); | ||
} | ||
|
||
} |
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