All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.haoxuer.discover.plug.data.service.impl.PluginServiceImpl Maven / Gradle / Ivy

/*
 * 
 * 
 * 
 */

package com.haoxuer.discover.plug.data.service.impl;

import com.haoxuer.discover.plug.api.PushPlugin;
import com.haoxuer.discover.plug.api.SendCodePlugin;
import com.haoxuer.discover.plug.api.StoragePlugin;
import com.haoxuer.discover.plug.data.service.PluginService;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.springframework.stereotype.Service;

/**
 * Service - 插件
 */
@Service("pluginServiceImpl")
public class PluginServiceImpl implements PluginService {

  @Resource
  private List paymentPlugins = new ArrayList();
  @Resource
  private List storagePlugins = new ArrayList();

  @Resource
  private List senCodePlugins = new ArrayList();

  @Resource
  private Map paymentPluginMap = new HashMap();

  @Resource
  private Map storagePluginMap = new HashMap();


  @Resource
  private Map sendCodePluginMap = new HashMap();

  public List getPushPlugins() {
    Collections.sort(paymentPlugins);
    return paymentPlugins;
  }

  public List getStoragePlugins() {
    Collections.sort(storagePlugins);
    return storagePlugins;
  }

  @Override
  public List getSendCodePlugins() {
    Collections.sort(senCodePlugins);
    return senCodePlugins;
  }

  public List getPushPlugins(final boolean isEnabled) {
    List result = new ArrayList();
    CollectionUtils.select(paymentPlugins, new Predicate() {
      public boolean evaluate(Object object) {
        PushPlugin paymentPlugin = (PushPlugin) object;
        return paymentPlugin.getIsEnabled() == isEnabled;
      }
    }, result);
    Collections.sort(result);
    return result;
  }

  public List getStoragePlugins(final boolean isEnabled) {
    List result = new ArrayList();
    CollectionUtils.select(storagePlugins, new Predicate() {
      public boolean evaluate(Object object) {
        StoragePlugin storagePlugin = (StoragePlugin) object;
        return storagePlugin.getIsEnabled() == isEnabled;
      }
    }, result);
    Collections.sort(result);
    return result;
  }

  @Override
  public List getSendCodePlugins(final boolean isEnabled) {
    List result = new ArrayList();
    CollectionUtils.select(senCodePlugins, new Predicate() {
      public boolean evaluate(Object object) {
        SendCodePlugin storagePlugin = (SendCodePlugin) object;
        return storagePlugin.getIsEnabled() == isEnabled;
      }
    }, result);
    Collections.sort(result);
    return result;
  }

  public PushPlugin getPushPlugin(String id) {
    return paymentPluginMap.get(id);
  }

  public StoragePlugin getStoragePlugin(String id) {
    return storagePluginMap.get(id);
  }

  @Override
  public SendCodePlugin getSendCodePlugin(String id) {
    return sendCodePluginMap.get(id);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy