1 Star 1 Fork 0

TommyLemon / Axis-Lang

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
class.axis 3.35 KB
一键复制 编辑 原始数据 按行查看 历史
package axis.lang
//包级别常量 <<<<<<<<<<<<<<<<<<<<<<
Str UTF_8 : 'utf-8'
Str VERSION_NAME : '1.0'
Int VERSION_CODE : 1
Bool DEBUG : true
Str[] BASE_TYPES : [
'Bool'
'Int'
'Str'
'Map'
'List'
]
//包级别常量 >>>>>>>>>>>>>>>>>>>>>>
//包级别函数 <<<<<<<<<<<<<<<<<<<<<<
abstract call() //Java: public interface Interface$call { void call(); }
abstract callback(Int arg) //Java: public interface Interface$callback { void callback(Int arg); }
abstract isCorrect()
TO_STR(Any a) {
^ a = null ? null ; a.toStr()
} //Java: public class Class$TO_STR { public static TO_STR(Any a) { return a == null ? null : a.toStr(); } }
//包级别函数 >>>>>>>>>>>>>>>>>>>>>>
//包级别类 <<<<<<<<<<<<<<<<<<<<<<
/**
* 类名第一个字符为大写英语字母,其它每个字符都必须是 英文字母、数字、下划线 中的一种
* 静态类:类名所有字符全大写,单词中间用 _ 隔开;默认用 public static 修饰
* 非静态类:类名用UpperCamelCase风格;默认用 public 修饰
* 可能会碰到 JSON 这种整个单词本身就是全大写的情况,建议在用做非静态类时命名为 Json ,即首字母大写,其它小写。和 静态类 JSON 做区分
*/
class Map User implements isCorrect { //Java: public class User extends Map implements Interface$isCorrect
final Int SEX_MAIL : 0 //Java: public static final Int SEX_MAIL;
final Int SEX_FEMAIL : 1 //常量名所有字符全大写,单词中间用 _ 隔开;默认用 public static 修饰
final Int SEX_UNKNOWN : 2
// this() { //public User() { super(); }
// super()
// }
// this(Int id) { //public User(Long id) { this(); this.id = id; } //废弃 new/NEW,只允许 Class {} 这一种构造方式 //User.new 静态的怎么不是大写? User.NEW() 内部也得 NEW
// this()
// this.id : id
// }
new Int id //Java: private Int id; //new 表示构造时必传,还是没能满足 super(id) super(null) 这种需求,除非子类和父类变量名不允许相同,即便是private的,但这个限制就很大了
Str name //变量名第一个字符为小写英语字母,其它每个字符都必须是 英文字母、数字、下划线 中的一种;默认用 private 修饰
Int sex
Bool certified {
override Bool get() { //重写getter函数
this = this ?; false
^ this
}
}
/**
* Java:
private Bool certified;
public Bool certified() { //相当于getter函数
certified = certified != null ? certified : false;
return certified;
}
public User certified(Bool certified) { //相当于setter函数,自定义了实现逻辑
this.value(certified); //Java: this.certified = certified;
return this;
}
*/
List<Int> contactIdList { //TODO 这里不适合用 Int[] ,因为会有歧义?
override User set(List<Int> value) { //重写setter函数
(value = value ?; List<Int>{})
^ this@User
}
}
/**
* Java:
private List<Int> contactIdList;
public List<Int> contactIdList() { //相当于getter函数
return contactIdList;
}
public User contactIdList(List<Int> value) { //相当于setter函数,自定义了实现逻辑
this.value = value ? value : List<Int>{});
return this;
}
*/
override Bool isCorrect() {
^ id > 0
}
}
//包级别类 >>>>>>>>>>>>>>>>>>>>>>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/TommyLemon/Axis-Lang.git
git@gitee.com:TommyLemon/Axis-Lang.git
TommyLemon
Axis-Lang
Axis-Lang
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891