Skip to content

Commit 86fd28f

Browse files
committed
Lint for the annotations utils
1 parent fd0de6f commit 86fd28f

2 files changed

Lines changed: 95 additions & 94 deletions

File tree

src/main/java/com/jwebmp/core/base/ComponentHierarchyBase.java

Lines changed: 92 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@
3636
import com.jwebmp.core.base.references.JavascriptReference;
3737
import com.jwebmp.core.base.servlets.enumarations.ComponentTypes;
3838
import com.jwebmp.core.base.servlets.interfaces.ICSSComponent;
39-
import com.jwebmp.core.databind.IAfterRenderComplete;
40-
import com.jwebmp.core.databind.IConfiguration;
41-
import com.jwebmp.core.databind.IOnComponentAdded;
42-
import com.jwebmp.core.databind.IOnComponentHtmlRender;
39+
import com.jwebmp.core.databind.*;
4340
import com.jwebmp.core.htmlbuilder.css.themes.Theme;
4441
import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent;
4542
import com.jwebmp.core.services.IPage;
@@ -69,8 +66,8 @@
6966
@SuppressWarnings({"unchecked",
7067
"MissingClassJavaDoc"})
7168
public class ComponentHierarchyBase<C extends GlobalChildren, A extends Enum<?> & AttributeDefinitions, F extends GlobalFeatures, E extends GlobalEvents, J extends ComponentHierarchyBase<C, A, F, E, J>> extends
72-
ComponentThemeBase<A, F, E, J> implements
73-
IComponentHierarchyBase<C, J>
69+
ComponentThemeBase<A, F, E, J> implements
70+
IComponentHierarchyBase<C, J>
7471
{
7572

7673
/**
@@ -138,15 +135,15 @@ public IComponentHierarchyBase<C, J> asHierarchyBase()
138135
for (C child : getChildren())
139136
{
140137
for (Object jScript : child.cast()
141-
.asHierarchyBase()
142-
.getEventsAll())
138+
.asHierarchyBase()
139+
.getEventsAll())
143140
{
144141
if (jScript == null)
145142
{
146143
continue;
147144
}
148145
if (((Event<?, ?>) jScript).getID()
149-
.equals(eventId))
146+
.equals(eventId))
150147
{
151148
return (ComponentEventBase<?, ?, ?>) jScript;
152149
}
@@ -167,11 +164,11 @@ public IComponentHierarchyBase<C, J> asHierarchyBase()
167164
public J setTiny(boolean tiny)
168165
{
169166
getChildren().stream()
170-
.filter(a -> a != null)
171-
.parallel()
172-
.forEach(child -> child.cast()
173-
.asBase()
174-
.setTiny(tiny));
167+
.filter(a -> a != null)
168+
.parallel()
169+
.forEach(child -> child.cast()
170+
.asBase()
171+
.setTiny(tiny));
175172
return super.setTiny(tiny);
176173
}
177174

@@ -186,7 +183,7 @@ private String getParentJSON()
186183
if (getParent() != null)
187184
{
188185
return getParent().asBase()
189-
.getID();
186+
.getID();
190187
}
191188
return null;
192189
}
@@ -206,8 +203,8 @@ public Set<CSSReference> getCssReferencesAll()
206203
if (child != null)
207204
{
208205
for (Object jScript : child.cast()
209-
.asDependencyBase()
210-
.getCssReferencesAll())
206+
.asDependencyBase()
207+
.getCssReferencesAll())
211208
{
212209
allCss.add((CSSReference) jScript);
213210
}
@@ -231,8 +228,8 @@ public Set<JavascriptReference> getJavascriptReferencesAll()
231228
if (child != null)
232229
{
233230
for (Object jScript : child.cast()
234-
.asDependencyBase()
235-
.getJavascriptReferencesAll())
231+
.asDependencyBase()
232+
.getJavascriptReferencesAll())
236233
{
237234
if (jScript != null)
238235
{
@@ -280,8 +277,7 @@ public void destroy()
280277
try
281278
{
282279
next.destroy();
283-
}
284-
catch (Exception e)
280+
} catch (Exception e)
285281
{
286282
ComponentHierarchyBase.log.log(Level.SEVERE, "UUnable to destroy", e);
287283
}
@@ -314,7 +310,7 @@ public void destroy()
314310
if (child != null)
315311
{
316312
for (Object event : child.asFeatureBase()
317-
.getFeatures())
313+
.getFeatures())
318314
{
319315
if (event != null)
320316
{
@@ -364,9 +360,9 @@ public void destroy()
364360
public <T extends IComponentHierarchyBase<?, ?>> T embed(@NotNull T component)
365361
{
366362
component.getChildren()
367-
.stream()
368-
.filter(Objects::nonNull)
369-
.forEach(a -> add((C) a));
363+
.stream()
364+
.filter(Objects::nonNull)
365+
.forEach(a -> add((C) a));
370366
return component;
371367
}
372368

@@ -606,8 +602,8 @@ public void setChildren(List<C> children)
606602
{
607603
componentsToAddTo.add((IComponentHierarchyBase<?, ?>) child);
608604
child.cast()
609-
.asHierarchyBase()
610-
.getChildrenHierarchy(componentsToAddTo);
605+
.asHierarchyBase()
606+
.getChildrenHierarchy(componentsToAddTo);
611607
}
612608
});
613609
return componentsToAddTo;
@@ -624,17 +620,17 @@ public void setChildren(List<C> children)
624620
{
625621
Set<IEvent<?, ?>> allEvents = new LinkedHashSet<>();
626622
getChildrenHierarchy(true).stream()
627-
.filter(Objects::nonNull)
628-
.forEach(child -> {
629-
for (Object event : child.asEventBase()
630-
.getEvents())
631-
{
632-
if (event != null)
633-
{
634-
allEvents.add((IEvent<?, ?>) event);
635-
}
636-
}
637-
});
623+
.filter(Objects::nonNull)
624+
.forEach(child -> {
625+
for (Object event : child.asEventBase()
626+
.getEvents())
627+
{
628+
if (event != null)
629+
{
630+
allEvents.add((IEvent<?, ?>) event);
631+
}
632+
}
633+
});
638634
return allEvents;
639635
}
640636

@@ -763,8 +759,7 @@ public boolean removeClass(@NotNull Enum<?> className)
763759
{
764760
getClasses().remove(className.toString());
765761
return true;
766-
}
767-
else
762+
} else
768763
{
769764
return false;
770765
}
@@ -853,7 +848,7 @@ public Set<String> getVariablesAll()
853848
if (child != null)
854849
{
855850
for (Object o : child.asFeatureBase()
856-
.getVariables())
851+
.getVariables())
857852
{
858853
if (o != null)
859854
{
@@ -901,8 +896,7 @@ public String toString(Integer tabCount)
901896
try
902897
{
903898
component.onComponentAdded(null, (ComponentHierarchyBase<?, ?, ?, ?, ?>) this);
904-
}
905-
catch (Throwable T)
899+
} catch (Throwable T)
906900
{
907901
log.log(Level.SEVERE, "Error on component added", T);
908902
}
@@ -932,8 +926,7 @@ protected StringBuilder renderHTML(int tabCount)
932926
{
933927
renderChildren = result;
934928
}
935-
}
936-
catch (Throwable T)
929+
} catch (Throwable T)
937930
{
938931
log.log(Level.WARNING, "Error in processing html render interceptor", T);
939932
}
@@ -1011,6 +1004,17 @@ protected void preConfigure()
10111004
setNewLineForClosingTag(hasChildren());
10121005
}
10131006
super.preConfigure();
1007+
Set<IOnComponentConfigured> components = IGuiceContext.loaderToSet(ServiceLoader.load(IOnComponentConfigured.class));
1008+
for (IOnComponentConfigured component : components)
1009+
{
1010+
try
1011+
{
1012+
component.onComponentConfigured(null, this);
1013+
} catch (Throwable T)
1014+
{
1015+
log.log(Level.SEVERE, "Error on component added", T);
1016+
}
1017+
}
10141018
}
10151019

10161020
/**
@@ -1026,7 +1030,7 @@ protected StringBuilder renderClasses()
10261030
StringBuilder sb = new StringBuilder();
10271031
Set<String> eachClass = getClasses();
10281032
eachClass.forEach(a -> sb.append(a)
1029-
.append(StaticStrings.STRING_SPACE));
1033+
.append(StaticStrings.STRING_SPACE));
10301034
if (sb.length() > 0)
10311035
{
10321036
sb.deleteCharAt(sb.length() - 1);
@@ -1101,14 +1105,14 @@ private void processComponentQueries(@NotNull IComponentHierarchyBase<?, ?> comp
11011105
reallyAllQueries.addAll(getQueries());
11021106
@SuppressWarnings("rawtypes")
11031107
List<ComponentFeatureBase<?, ?>> features = new ArrayList(componentQuery.asFeatureBase()
1104-
.getFeatures());
1108+
.getFeatures());
11051109
features.forEach(feature -> reallyAllQueries.add(feature.renderJavascript()));
11061110
features.sort(comparing(ComponentFeatureBase::getSortOrder));
11071111
Set<GlobalEvents> events = (Set<GlobalEvents>) componentQuery.asEventBase()
1108-
.getEvents();
1112+
.getEvents();
11091113

11101114
events.forEach(event -> reallyAllQueries.add(((IComponentFeatureBase<?, ?>) event).asFeatureBase()
1111-
.renderJavascript()));
1115+
.renderJavascript()));
11121116

11131117
features.sort(comparing(ComponentFeatureBase::getSortOrder));
11141118
}
@@ -1126,10 +1130,10 @@ public J setPage(IPage<?> page)
11261130
{
11271131
this.page = page;
11281132
getChildren().stream()
1129-
.filter(a -> a != null)
1130-
.forEach(child -> child.cast()
1131-
.asHierarchyBase()
1132-
.setPage(page));
1133+
.filter(a -> a != null)
1134+
.forEach(child -> child.cast()
1135+
.asHierarchyBase()
1136+
.setPage(page));
11331137
return (J) this;
11341138
}
11351139

@@ -1142,8 +1146,8 @@ public J setPage(IPage<?> page)
11421146
private void processAngularObjects(@NotNull IComponentHierarchyBase<?, ?> next, @NotNull Map<String, Object> map)
11431147
{
11441148
for (Map.Entry<String, Object> entry : next.asAngularBase()
1145-
.getJsonObjects()
1146-
.entrySet())
1149+
.getJsonObjects()
1150+
.entrySet())
11471151
{
11481152
String key = entry.getKey();
11491153
Object value = entry.getValue();
@@ -1152,12 +1156,10 @@ private void processAngularObjects(@NotNull IComponentHierarchyBase<?, ?> next,
11521156
try
11531157
{
11541158
map.put(key, value);
1155-
}
1156-
catch (ClassCastException cce)
1159+
} catch (ClassCastException cce)
11571160
{
11581161
ComponentHierarchyBase.log.log(Level.WARNING, "Incorrect Object Type, Perhaps JavaScriptPart?", cce);
1159-
}
1160-
catch (Exception e)
1162+
} catch (Exception e)
11611163
{
11621164
ComponentHierarchyBase.log.log(Level.WARNING, "Unable to render angular object", e);
11631165
}
@@ -1184,14 +1186,13 @@ public boolean readChildrenPropertyFirstResult(String propertyName, boolean retu
11841186
.containsKey(propertyName))
11851187
{
11861188
String propertyValue = next.asBase()
1187-
.getProperties()
1188-
.get(propertyName)
1189-
.toString();
1189+
.getProperties()
1190+
.get(propertyName)
1191+
.toString();
11901192
try
11911193
{
11921194
return Boolean.parseBoolean(propertyValue);
1193-
}
1194-
catch (Exception e)
1195+
} catch (Exception e)
11951196
{
11961197
ComponentHierarchyBase.log.log(Level.WARNING, "Property value was not a boolean.", e);
11971198
}
@@ -1249,10 +1250,10 @@ public boolean readChildrenPropertyFirstResult(String propertyName, boolean retu
12491250
public <T extends IComponentHierarchyBase<?, ?>> T findChild(@NotNull Class<T> childType)
12501251
{
12511252
return (T) getChildren().stream()
1252-
.filter(componentHierarchyBase -> componentHierarchyBase.getClass()
1253-
.equals(childType))
1254-
.findFirst()
1255-
.orElse(null);
1253+
.filter(componentHierarchyBase -> componentHierarchyBase.getClass()
1254+
.equals(childType))
1255+
.findFirst()
1256+
.orElse(null);
12561257
}
12571258

12581259
/**
@@ -1301,23 +1302,22 @@ protected StringBuilder renderChildren()
13011302
//CopyOnWriteArraySet<C> objects = new CopyOnWriteArraySet<>();
13021303
//objects.addAll(getChildren());
13031304
getChildren().stream()
1304-
//objects.stream()
1305-
.filter(Objects::nonNull)
1306-
.forEach(child -> {
1307-
if (child instanceof ComponentHierarchyBase<?, ?, ?, ?, ?> chb)
1308-
{
1309-
try
1310-
{
1311-
sb.append(getNewLine())
1312-
.append(chb.renderHTML(getCurrentTabIndents() + (chb.isTiny() ? 0 : 1)));
1313-
}
1314-
catch (Exception e)
1315-
{
1316-
log.log(Level.SEVERE, "Cannot work on child object - " + child.getClass()
1317-
.getCanonicalName() + "\n, adding to the tree\n", e);
1318-
}
1319-
}
1320-
});
1305+
//objects.stream()
1306+
.filter(Objects::nonNull)
1307+
.forEach(child -> {
1308+
if (child instanceof ComponentHierarchyBase<?, ?, ?, ?, ?> chb)
1309+
{
1310+
try
1311+
{
1312+
sb.append(getNewLine())
1313+
.append(chb.renderHTML(getCurrentTabIndents() + (chb.isTiny() ? 0 : 1)));
1314+
} catch (Exception e)
1315+
{
1316+
log.log(Level.SEVERE, "Cannot work on child object - " + child.getClass()
1317+
.getCanonicalName() + "\n, adding to the tree\n", e);
1318+
}
1319+
}
1320+
});
13211321
if (renderAfterChildren() != null)
13221322
{
13231323
sb.append(renderAfterChildren());
@@ -1340,8 +1340,7 @@ public Boolean isNewLineForClosingTag()
13401340
if (hasChildren() && !isTiny())
13411341
{
13421342
return true;
1343-
}
1344-
else
1343+
} else
13451344
{
13461345
return super.isNewLineForClosingTag();
13471346
}
@@ -1402,16 +1401,15 @@ public <T> Set<T> getConfigurations(Class<T> configurationType, boolean children
14021401
{
14031402
ComponentHierarchyBase chb = (ComponentHierarchyBase) iComponentHierarchyBase;
14041403
out.addAll((Set<T>) chb.getConfigurations()
1405-
.stream()
1406-
.filter(b -> configurationType.isAssignableFrom(b.getClass()))
1407-
.collect(Collectors.toSet()));
1404+
.stream()
1405+
.filter(b -> configurationType.isAssignableFrom(b.getClass()))
1406+
.collect(Collectors.toSet()));
14081407
}
1409-
}
1410-
else
1408+
} else
14111409
{
14121410
out.addAll((Collection<? extends T>) getConfigurations().stream()
1413-
.filter(b -> configurationType.isAssignableFrom(b.getClass()))
1414-
.collect(Collectors.toList()));
1411+
.filter(b -> configurationType.isAssignableFrom(b.getClass()))
1412+
.collect(Collectors.toList()));
14151413
}
14161414
return out;
14171415
}

0 commit comments

Comments
 (0)