public StateHolder generateStateHolder(String name, boolean groupBy, StateFactory stateFactory, boolean unSafe) {
        if (stateFactory != null) {
            StateHolder stateHolder;
            if (unSafe) {
                if (partitioned || groupBy) {
                    stateHolder = new PartitionStateHolder(stateFactory);
                } else {
                    stateHolder = new SingleStateHolder(stateFactory);
                }
            } else {
                if (partitioned || groupBy) {
                    stateHolder = new PartitionSyncStateHolder(stateFactory);
                } else {
                    stateHolder = new SingleSyncStateHolder(stateFactory);
                }
            }

            if (SnapshotService.getSkipStateStorageThreadLocal().get() == null ||
                    !SnapshotService.getSkipStateStorageThreadLocal().get()) {
                Map<String, StateHolder> stateHolderMap =
                        siddhiAppContext.getSnapshotService().getStateHolderMap(partitionId, this.getName());
                stateHolderMap.put(idGenerator.createNewId() + "-" + name, stateHolder);
            }
            stateful = true;
            return stateHolder;
        } else {
            return new EmptyStateHolder();
        }
    }
Holder object for context information of {@link SiddhiApp}.
modules/siddhi-core/src/main/java/io/siddhi/core/config/SiddhiQueryContext.java