This method MUST retain the state of the current instance, and return
an instance that contains the specified authority.
546763
function it_retains_the_original_state_of_the_instance_duplicated_with_new_authority()
    {
        $original_uri = (string) $this->getWrappedObject();

        $new_authority = $this->withAuthority("corge:grault@quux.qux:9999");

        $this->__toString()->shouldReturn($original_uri);
    }
1273346
def authority
      self.host && @authority ||= begin
        authority = String.new
        if self.userinfo != nil
          authority << "#{self.userinfo}@"
        end
        authority << self.host
        if self.port != nil
          authority << ":#{self.port}"
        end
        authority
      end
    end
1192474
public static final synchronized StateManager getInstance(Object context) {
		
		return (instance == null)? 
				(instance = new StateService(ContextUtils.asApplication(context))) :instance;
	}
1067871
public static String checkAuthority(String authority) {
    URI uri = authorityToUri(authority);
    checkArgument(uri.getHost() != null, "No host in authority '%s'", authority);
    checkArgument(uri.getUserInfo() == null,
        "Userinfo must not be present on authority: '%s'", authority);
    return authority;
  }
179262
def state(self):
        """"""
        state = self._resource.get('state', self.default_state)

        if state in State:
            return state
        else:
            return getattr(State, state)
122701
public function checkAuthorization($authorization, $client_id, $access_token) {
        $instance = new checkAuthorization($this, $this->getUserAgent(), $authorization, $client_id, $access_token);
        return $instance;
    }
353740
public E retrieve() {
        switch (accessPolicy) {
            case LIFO:
                return deque.pollLast();
            case FIFO:
                return deque.pollFirst();
            default:
                throw new IllegalStateException("Illegal evict policy: " + evictPolicy);
        }
    }
403331
def _control(self, state):
        

        # Renew subscription if necessary
        if not self._subscription_is_recent():
            self._subscribe()

        cmd = MAGIC + CONTROL + self._mac + PADDING_1 + PADDING_2 + state
        _LOGGER.debug("Sending new state to %s: %s", self.host, ord(state))
        ack_state = self._udp_transact(cmd, self._control_resp, state)
        if ack_state is None:
            raise S20Exception(
                "Device didn't acknowledge control request: {}".format(
                    self.host))
1198302
private Decision internalEvaluate(
            Map<String, String> resource, Subject subject, String action,
            Set<Attribute> environment, List<AclRule> matchingRules
    )
    {
        long start = System.currentTimeMillis();
        if (matchingRules.size() < 1) {
            return authorize(
                    false,
                    "No context matches subject or environment",
                    Explanation.Code.REJECTED_NO_SUBJECT_OR_ENV_FOUND,
                    resource,
                    subject,
                    action,
                    environment,
                    System.currentTimeMillis() - start
            );
        }
        if (resource == null) {
            throw new IllegalArgumentException(
                    "Resource does not identify any resource because it's an empty resource property or null."
            );
        } else {
            for (Map.Entry<String, String> entry : resource.entrySet()) {
                if (entry.getKey() == null) {
                    throw new IllegalArgumentException("Resource definition cannot contain null property name.");
                }
                if (entry.getValue() == null) {
                    throw new IllegalArgumentException(
                            "Resource definition cannot contain null value.  Corresponding key: " + entry.getKey()
                    );
                }
            }
        }

        if (subject == null) {
            throw new IllegalArgumentException("Invalid subject, subject is null.");
        }
        if (action == null || action.length() <= 0) {
            return authorize(
                    false,
                    "No action provided.",
                    Explanation.Code.REJECTED_NO_ACTION_PROVIDED,
                    resource,
                    subject,
                    action,
                    environment,
                    System.currentTimeMillis() - start
            );
        }
        // environment can be null.
        if (environment == null) {
            environment = Collections.emptySet();
        }


        ContextDecision contextDecision = null;
        ContextDecision lastDecision = null;

        //long contextIncludeStart = System.currentTimeMillis();
        boolean granted = false;
        boolean denied = false;
        for (AclRule rule : matchingRules) {
            final ContextDecision includes = ruleIncludesResourceAction(rule, resource, action);
            if (Explanation.Code.REJECTED_DENIED == includes.getCode()) {
                contextDecision = includes;
                denied = true;
                return createAuthorize(
                        false, contextDecision, resource, subject, action, environment,
                        System.currentTimeMillis() - start
                );
            } else if (includes.granted()) {
                contextDecision = includes;
                granted = true;
            }
            lastDecision = includes;
        }
        if (granted) {
            return createAuthorize(
                    true, contextDecision, resource, subject, action, environment,
                    System.currentTimeMillis() - start
            );
        }

        if (lastDecision == null) {
            return authorize(
                    false,
                    "No resource or action matched.",
                    Explanation.Code.REJECTED_NO_RESOURCE_OR_ACTION_MATCH,
                    resource,
                    subject,
                    action,
                    environment,
                    System.currentTimeMillis() - start
            );
        } else {
            return createAuthorize(
                    false,
                    lastDecision,
                    resource,
                    subject,
                    action,
                    environment,
                    System.currentTimeMillis() - start
            );
        }
    }
288738
def join_authority(authority):
    
    (user, passwd, host, port) = authority
    result = ''
    if user:
        result += user
        if passwd:
            result += ':' + passwd
        result += '@'
    result += host
    if port:
        result += ':' + port
    return result
863680
def _get_instance_state(self):
        
        instance = self._get_instance()
        statuses = instance.instance_view.statuses

        for status in statuses:
            if status.code.startswith('PowerState'):
                return status.display_status
612420
def get_state(self, as_str=False):
        

        uid = self.user_id

        if self._iface_user.get_id() == uid:
            result = self._iface.get_my_state()

        else:
            result = self._iface.get_state(uid)

        if as_str:
            return UserState.get_alias(result)

        return result
518825
public PermissionsBuilder setState(PermissionType type, PermissionState state) {
        delegate.setState(type, state);
        return this;
    }
602943
private Collection<SagaInstanceInfo> continueExistingSaga(final SagaType sagaType, final Object instanceKey) {
        Collection<SagaInstanceInfo> sagas = new ArrayList<>();

        Collection<? extends SagaState> sagaStates = stateStorage.load(sagaType.getSagaClass().getName(), instanceKey);
        for (SagaState sagaState : sagaStates) {
            try {
                Saga saga = instanceFactory.continueExisting(sagaType.getSagaClass(), sagaState);
                sagas.add(SagaInstanceInfo.define(saga, false));
            } catch (ExecutionException e) {
                Throwables.propagate(e);
            }
        }

        return sagas;
    }
270372
def set_state(self, entity_id, new_state, **kwargs):
        ""
        return remote.set_state(self.api, new_state, **kwargs)
774554
def state(self):
        
        if self._proto.HasField('state'):
            return yamcsManagement_pb2.YamcsInstance.InstanceState.Name(self._proto.state)
        return None
1019032
public function refresh(Model $authority = null)
    {
        if ($this->usesCachedClipboard()) {
            $this->getClipboard()->refresh($authority);
        }

        return $this;
    }