Skip to content

Commit

Permalink
WebuiRelatedProcessDescriptor shall memorize the preconditionsResolut…
Browse files Browse the repository at this point in the history
…ionSupplier

#330
  • Loading branch information
teosarca committed May 3, 2017
1 parent 7ed0bdd commit a5af6a8
Showing 1 changed file with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.function.Supplier;

import org.adempiere.util.Check;
import org.adempiere.util.lang.ExtendedMemorizingSupplier;

import com.google.common.collect.ImmutableMap;

Expand Down Expand Up @@ -43,7 +44,6 @@
* @author metas-dev <dev@metasfresh.com>
*
*/
@lombok.Builder
public final class WebuiRelatedProcessDescriptor
{
public static final WebuiRelatedProcessDescriptor of( //
Expand All @@ -55,7 +55,7 @@ public static final WebuiRelatedProcessDescriptor of( //
Check.assumeNotNull(relatedProcessDescriptor, "Parameter relatedProcessDescriptor is not null");
Check.assumeNotNull(processDescriptor, "Parameter processDescriptor is not null");
Check.assume(relatedProcessDescriptor.getProcessId() == processDescriptor.getProcessId().getProcessIdAsInt(), "AD_Process_ID matching for {} and {}", relatedProcessDescriptor, processDescriptor);

return builder()
.processId(processDescriptor.getProcessId())
.processCaption(processDescriptor.getCaption())
Expand All @@ -77,9 +77,34 @@ public static final WebuiRelatedProcessDescriptor of( //
private final boolean defaultQuickAction;
@NonNull
private final Supplier<ProcessPreconditionsResolution> preconditionsResolutionSupplier;

private final String debugProcessClassname;

@lombok.Builder
private WebuiRelatedProcessDescriptor( //
final ProcessId processId //
, final ITranslatableString processCaption //
, final ITranslatableString processDescription //
, final boolean quickAction //
, final boolean defaultQuickAction //
, @NonNull final Supplier<ProcessPreconditionsResolution> preconditionsResolutionSupplier //
, final String debugProcessClassname //
)
{
super();
this.processId = processId;
this.processCaption = processCaption;
this.processDescription = processDescription;
this.quickAction = quickAction;
this.defaultQuickAction = defaultQuickAction;

// Memorize the resolution supplier to make sure it's not invoked more than once because it might be an expensive operation.
// Also we assume this is a short living instance which was created right before checking
this.preconditionsResolutionSupplier = ExtendedMemorizingSupplier.of(preconditionsResolutionSupplier);

this.debugProcessClassname = debugProcessClassname;
}

public ProcessId getProcessId()
{
return processId;
Expand Down

0 comments on commit a5af6a8

Please sign in to comment.