shared abstract class AbstractOp<T>() of T given T satisfies AbstractOp<T> {
/**
* SQL FROM clause
* @return Returns this object
* @param table The table to use with FROM clause
*/
shared overloaded default T from(Table table) {
op().append(" FROM ");
op().append(table.getTableName());
return (this) of T;
}
/**
* SQL FROM clause.
* @return Returns this object
* @param tables The tables to use with FROM clause
*/
shared overloaded T from({Table*} tables) {
value len = tables.size;
variable Integer cnt = 1;
op().append(" FROM(");
for(table in tables){
op().append(table.getTableName());
if(cnt++ < len){
op().append(",");
}
}
op().append(")");
return (this) of T;
}
}
I've another class where I'm using overloaded annotation for static methods:
shared class ColumnValue {
shared overloaded static ColumnValue setVal(Column column, Anything val) {
if(!isValid(val)) {
throw Exception("Invalid type passed for table column:``column`` ");
}
return ColumnValue(column,val);
}
shared overloaded static ColumnValue setVal(Anything val) {
if(!isValid(val)) {
throw Exception("Invalid value passed.");
}
return ColumnValue(Column(""),val);
}
Column column;
Anything val;
new(Column column, Anything val){
this.column = column;
this.val = val;
}
shared Anything getValue() => val;
shared Column getColumn() => column;
}
Now, I'm trying to import the method "setVal" statically but it fails..."Illegal static import, setVal is not static"
However, it allows to use setVal if:
1) I call it using ColumnValue.setVal("Germany");
2) It allows static import if I remove the overloaded annotation and name the two methods differently as below:
shared class ColumnValue {
shared static ColumnValue set(Column column, Anything val) {
if(!isValid(val)) {
throw Exception("Invalid type passed for table column:``column`` ");
}
return ColumnValue(column,val);
}
shared static ColumnValue setVal(Anything val) {
if(!isValid(val)) {
throw Exception("Invalid value passed.");
}
return ColumnValue(Column(""),val);
}
Column column;
Anything val;
new(Column column, Anything val){
this.column = column;
this.val = val;
}
shared Anything getValue() => val;
shared Column getColumn() => column;
}