-
Notifications
You must be signed in to change notification settings - Fork 165
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
8 changed files
with
154 additions
and
23 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
99 changes: 99 additions & 0 deletions
99
hsweb-easy-orm-core/src/main/java/org/hswebframework/ezorm/core/Extendable.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,99 @@ | ||
package org.hswebframework.ezorm.core; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* 可扩展的对象,用于动态拓展实体字段属性 | ||
* | ||
* @author zhouhao | ||
* @since 4.1.3 | ||
*/ | ||
public interface Extendable { | ||
|
||
/** | ||
* 获取所有扩展属性 | ||
* | ||
* @return 扩展属性 | ||
*/ | ||
@JsonAnyGetter | ||
Map<String, Object> extensions(); | ||
|
||
/** | ||
* 获取扩展属性 | ||
* | ||
* @param property 属性名 | ||
* @return 属性值 | ||
*/ | ||
default Object getExtension(String property) { | ||
Map<String, Object> ext = extensions(); | ||
return ext == null ? null : ext.get(property); | ||
} | ||
|
||
/** | ||
* 设置扩展属性 | ||
* | ||
* @param property 属性名 | ||
* @param value 属性值 | ||
*/ | ||
@JsonAnySetter | ||
void setExtension(String property, Object value); | ||
|
||
default void setExtension(String property, int value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, long value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, double value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, float value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, boolean value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, byte value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, char value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
default void setExtension(String property, short value) { | ||
setExtension(property, (Object) value); | ||
} | ||
|
||
|
||
/** | ||
* 方法引用方式设置扩展属性 | ||
* | ||
* @param property 属性名 | ||
* @param value 属性值 | ||
* @param <T> 属性值类型 | ||
*/ | ||
default <T> void withExtension(StaticMethodReferenceColumn<T> property, T value) { | ||
setExtension(property.getColumn(), value); | ||
} | ||
|
||
/** | ||
* 方法引用方式设置扩展属性 | ||
* | ||
* @param property 属性名 | ||
* @param <T> 属性值类型 | ||
*/ | ||
default <T> void withExtension(MethodReferenceColumn<T> property) { | ||
setExtension(property.getColumn(), property.get()); | ||
} | ||
|
||
} |
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
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