package com.godmonth.status.advancer.impl2;

import com.godmonth.status.advancer.intf.AdvancerBinding;
import com.godmonth.status.advancer.intf.StatusAdvancer;
import lombok.AccessLevel;
import lombok.Setter;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.FactoryBean;

import javax.annotation.PostConstruct;

@Setter
public class AdvancerBindingFactoryBean implements FactoryBean<AdvancerBinding> {
    protected Object availableStatus;

    protected Object expectedInstruction;

    protected StatusAdvancer statusAdvancer;

    @Setter(value = AccessLevel.NONE)
    protected AdvancerBinding advancerBinding;

    public Object getKey() {

        if (expectedInstruction != null) {
            return Pair.of(availableStatus, expectedInstruction);
        } else {
            return availableStatus;
        }
    }

    @PostConstruct
    public void init() {
        Object key = getKey();
        advancerBinding = AdvancerBinding.builder().key(key).statusAdvancer(statusAdvancer).build();
    }

    @Override
    public AdvancerBinding getObject() throws Exception {
        return advancerBinding;
    }

    @Override
    public Class<?> getObjectType() {
        return AdvancerBinding.class;
    }
}

@@ -155,35 +155,9 @@
 ncer
-;%0Aimport lombok.AccessLevel
+2
 ;%0Aim
@@ -404,16 +404,29 @@
 nding%3E %7B
+%0A%0A    @Setter
 %0A    pro
@@ -457,16 +457,28 @@
 tatus;%0A%0A
+    @Setter%0A
     prot
@@ -512,16 +512,28 @@
 ction;%0A%0A
+    @Setter%0A
     prot
@@ -552,16 +552,17 @@
 Advancer
+2
  statusA
@@ -575,46 +575,8 @@
 r;%0A%0A
-    @Setter(value = AccessLevel.NONE)%0A
     

update AdvancerBinding