Skip to content

Commit 6dbe7c6

Browse files
author
zhourenjian@gmail.com
committed
Ignore copy right year in generating RPC/Pipe classes
1 parent a4005a1 commit 6dbe7c6

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

sources/net.sf.j2s.ajax/generator/net/sf/j2s/ajax/SimpleSource4Java.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ public static String generateSourceFromObject(SimpleSerializable s) {
206206
}
207207

208208
Type[] interfaces = s.getClass().getGenericInterfaces();
209+
List<Type> interfaceList = new ArrayList<Type>();
209210
if (interfaces != null && interfaces.length > 0) {
210211
for (int i = 0; i < interfaces.length; i++) {
211212
Class<?> t = (Class<?>) interfaces[i];
212213
if (!SimpleSerializable.isSubInterfaceOf(t, ISimpleConstant.class)) {
213214
continue;
214215
}
216+
interfaceList.add(t);
215217
String typeName = t.getName();
216218
hasMoreImports = true;
217219
if (!importedClasses.contains(typeName)) {
@@ -329,10 +331,10 @@ public int compare(Class<?> c1, Class<?> c2) {
329331
source.append(simpleClazzName);
330332
}
331333

332-
if (interfaces != null && interfaces.length > 0) {
334+
if (interfaceList.size() > 0) {
333335
boolean keywordAppended = false;
334-
for (int i = 0; i < interfaces.length; i++) {
335-
Class<?> t = (Class<?>) interfaces[i];
336+
for (int i = 0; i < interfaceList.size(); i++) {
337+
Class<?> t = (Class<?>) (Type) interfaceList.get(i);
336338
if (!SimpleSerializable.isSubInterfaceOf(t, ISimpleConstant.class)) {
337339
continue;
338340
}
@@ -348,7 +350,7 @@ public int compare(Class<?> c1, Class<?> c2) {
348350
}
349351

350352
source.append(simpleTypeName);
351-
if (i != interfaces.length -1) {
353+
if (i != interfaceList.size() -1) {
352354
source.append(", ");
353355
}
354356
}

sources/net.sf.j2s.ajax/generator/net/sf/j2s/ajax/SourceUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.FileOutputStream;
77
import java.io.IOException;
88
import java.util.ArrayList;
9+
import java.util.Date;
910
import java.util.HashMap;
1011
import java.util.Iterator;
1112
import java.util.List;
@@ -175,6 +176,13 @@ public static void updateSourceContent(File file, String source) {
175176

176177
if (source.equals(oldSource)) {
177178
return;
179+
} else {
180+
@SuppressWarnings("deprecation")
181+
String copyrightYear = "* Copyright (c) " + (new Date().getYear() + 1900);
182+
String updatedSource = oldSource.replaceFirst("\\* Copyright \\(c\\) \\d{4}", copyrightYear);
183+
if (source.equals(updatedSource)) {
184+
return;
185+
}
178186
}
179187
}
180188
FileOutputStream fos = null;

0 commit comments

Comments
 (0)