1212import java .util .ArrayList ;
1313import java .util .Collection ;
1414import java .util .Collections ;
15+ import java .util .HashMap ;
1516import java .util .List ;
17+ import java .util .Map ;
1618import java .util .Optional ;
1719import net .sf .jsqlparser .schema .Table ;
1820import net .sf .jsqlparser .statement .Statement ;
@@ -24,6 +26,7 @@ public class Drop implements Statement {
2426 private String type ;
2527 private Table name ;
2628 private List <String > parameters ;
29+ private Map <String , List <String >> typeToParameters = new HashMap <>();
2730 private boolean ifExists = false ;
2831
2932 @ Override
@@ -63,18 +66,41 @@ public void setIfExists(boolean ifExists) {
6366 this .ifExists = ifExists ;
6467 }
6568
69+ public Map <String , List <String >> getTypeToParameters () {
70+ return typeToParameters ;
71+ }
72+
73+ public void setTypeToParameters (Map <String , List <String >> typeToParameters ) {
74+ this .typeToParameters = typeToParameters ;
75+ }
76+
6677 @ Override
6778 public String toString () {
6879 String sql = "DROP " + type + " "
6980 + (ifExists ? "IF EXISTS " : "" ) + name .toString ();
7081
82+ if (type .equals ("FUNCTION" )) {
83+ sql += formatFuncParams (getParamsByType ("FUNCTION" ));
84+ }
85+
7186 if (parameters != null && !parameters .isEmpty ()) {
7287 sql += " " + PlainSelect .getStringList (parameters );
7388 }
7489
7590 return sql ;
7691 }
7792
93+ public static String formatFuncParams (List <String > params ) {
94+ if (params == null ) {
95+ return "" ;
96+ }
97+ return params .isEmpty () ? "()" : PlainSelect .getStringList (params , true , true );
98+ }
99+
100+ public List <String > getParamsByType (String type ) {
101+ return typeToParameters .get (type );
102+ }
103+
78104 public Drop withIfExists (boolean ifExists ) {
79105 this .setIfExists (ifExists );
80106 return this ;
0 commit comments