Perforce servers running in "unicode" or "internationalized" are unsupported.
I would like to have this fixed for v1.0, but unfortunately there are some major changes that need to happen. My plan is to fix this for 2.0, and therefore will only run on the 2.0 Framework.Direct manipulation of the form text is not supported. That is, there is no way get the raw text of a form command or to save a form with the raw text. Instead, you must use the P4Form object.
There is currently no way to obtain an in-memory stream of file contents using the 'print' command. In other APIs, if multiple files are output using 'print', the contents of the file are concatenated into one in-memory variable. I have an idea that would correct this behavior, but it is more complex to consume. So I've punted on the idea for now, and it is unsupported.
The parsed output for the of the filelog command is awkward. In the native C++ api, the integration metadata is a sparse 2 dimensional array. The parsing logic in P4.Net does not account for this, so you end up with an ArrayFieldDictionary with keys like 'fromFile1,'. So, I could fix this, and come up with some sort of TwoDimArrayFieldDictionary. However, the trying to make sense of the filelog output using the 2-d arrays will almost certainly give you a headache. Instead, I want to research Tony Smith's implementation in P4Ruby. He has created an object model that represents the filelog metadata in an easy-to-use interface.
In P4.Net, thereís no straight-forward way to submit the default pending changelist. This is by design. If the client workspace has opened files in the default changelist before any P4.Net automation runs, those files will "come along for the ride" when you submit the default changelist. If the user has a JobView set, all jobs in that JobView will automatically be fixed when you submit that default changelist. Both of those behaviors are almost never desired, and Iíve found many scripts that have those bugs.
Note, starting in 2006.2, Perforce has native support for automatically submitting the default changelist. This is accomplished with: p4 submit -d "change description". I caution it's usage, as it has the same limitations decribed above.
You can not change the P4Port setting after a P4Connection has been connected. This is true even after a Disconnect(). Instead, create a new P4Connection object.
Servers lower than 2004.2 begin to fail the unit tests. However, it is not a complete failure. One issue is the use of p4 login. The other failure is in the ConvertDate methods, because they use p4 info in parsed mode to determine the server's time zone. If you avoid those methods, P4.Net should work fine against older servers.


Shane Smith & The Saints hail out of Austin, Texas. Blending a four-part harmony with hints of aggresive folk, rock and rootsy fiddle filled Americana. Featuring two produced albums, Coast (2015) and Geronimo (2016). This group of guys is bound to leave you asking for more during a live show that you can catch at a small local dive bar throughout the midwest region of the United States.
They laughed at my boots because they have more holes than a fishing net,
Runaway Train - Geronimo (2016)
But that's fine, they work just fine. I was born to run, so run I may.
Come take my hand on this runaway train.


My name is Ryan B.
I am 25 years old.
I like to play Games.
I have a bachelors degree in History from UNM.
HIGH FIVE!


Math
Calculator simulator
This
is a simulation of a calculator capable of being programmed in Python, graphing, and many more functions. Source: NumWorks
Formulas
Home Page


"""The body class."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from robovat.simulation.body import Body
from robovat.utils.logging import logger
# Default simulation parameters for the Sawyer robot.
TIMEOUT = 15.0
POSITION_THRESHOLD = 0.008726640
VELOCITY_THRESHOLD = 0.05
POSITION_GAIN = 0.05
VELOCITY_GAIN = 1.0
JOINT_DAMPING = 0.7
# Number of steps to check if the target has been reached.
STEPS_TO_CHECK_DONE = 100
# Number of steps to recompute IK during simulation.
STEPS_TO_UPDATE_IK = 10
[docs]class JointTarget(object):
"""Specify the target in terms of joint positions and velocities."""
def __init__(self, body):
self._body = body
self.reset()
@property
def indices(self):
return self._indices
@property
def positions(self):
return self._positions
@property
def velocities(self):
return self._velocities
@property
def start_time(self):
return self._start_time
@property
def stop_time(self):
return self._stop_time
@property
def position_gains(self):
return self._position_gains
@property
def velocity_gains(self):
return self._velocity_gains
@property
def position_threshold(self):
return self._position_threshold
@property
def velocity_threshold(self):
return self._velocity_threshold
[docs] def is_ready(self):
"""Check if the target has been reached.
Returns:
True if the target has been reached, False otherwise.
"""
return self._indices is None
[docs] def reset(self):
"""Reset the target."""
self._indices = None
self._positions = None
self._velocities = None
self._start_time = None
self._stop_time = None
self._position_gains = None
self._velocity_gains = None
self._position_threshold = None
self._velocity_threshold = None
[docs] def set(self,
indices,
positions,
velocities,
start_time=None,
stop_time=None,
position_gains=None,
velocity_gains=None,
position_threshold=None,
velocity_threshold=None,
timeout=TIMEOUT):
"""Set the target.
Args:
indices: Joint indices.
positions: Target joint positions.
velocities: Target joint velocities.
start_time: Starting time of the target.
stop_time: Stopping time of the target.
position_gains: Position gain of position control.
velocity_gains: Velocity gain of position control.
position_threshold: Threshold of reaching the target positions.
velocity_threshold: Threshold of reaching the target velocities.
timeout: Maximum execution time in seconds.
"""
self._indices = indices
self._positions = positions
self._velocities = velocities
self._start_time = start_time or self._body.physics.time()
self._stop_time = stop_time or self._start_time + timeout
num_joints = len(indices)
self._position_gains = position_gains or [POSITION_GAIN] * num_joints
self._velocity_gains = velocity_gains or [VELOCITY_GAIN] * num_joints
self._position_threshold = position_threshold or POSITION_THRESHOLD
self._velocity_threshold = velocity_threshold or VELOCITY_THRESHOLD
[docs]class LinkTarget(object):
"""Specify the target in terms of pose of a link."""
def __init__(self, body):
self._body = body
self.reset()
@property
def index(self):
return self._index
@property
def link(self):
return self._link
@property
def pose(self):
return self._pose
@property
def pose_queue(self):
return self._pose_queue
@property
def start_time(self):
return self._start_time
@property
def position_threshold(self):
return self._position_threshold
@property
def velocity_threshold(self):
return self._velocity_threshold
@property
def stop_time(self):
return self._stop_time
[docs] def is_ready(self):
"""Check if the target has been reached.
Returns:
True if the target has been reached, False otherwise.
"""
return self._index is None
[docs] def reset(self):
"""Reset the target."""
self._index = None
self._link = None
self._pose = None
self._pose_queue = []
self._start_time = None
self._stop_time = None
[docs] def set(self,
index,
pose,
start_time=None,
stop_time=None,
position_threshold=None,
velocity_threshold=None,
timeout=TIMEOUT):
"""Set the target.
Args:
index: Link index.
pose: Target link pose.
start_time: Starting time of the target.
stop_time: Stopping time of the target.
position_threshold: Threshold of reaching the target positions.
velocity_threshold: Threshold of reaching the target velocities.
timeout: Maximum execution time in seconds.
"""
self._index = index
self._link = self._body.links[index]
if isinstance(pose, list):
self._pose = None
self._pose_queue = pose
else:
self._pose = pose
self._pose_queue = []
self._start_time = start_time or self._body.physics.time()
self._stop_time = stop_time or self._start_time + timeout
self._position_threshold = position_threshold or POSITION_THRESHOLD
self._velocity_threshold = velocity_threshold or VELOCITY_THRESHOLD
[docs] def pop(self):
if len(self._pose_queue) == 0:
self.reset()
else:
self._pose = self._pose_queue[0]
self._pose_queue = self._pose_queue[1:]
return self._pose
[docs]class ControllableBody(Body):
"""Body."""
def __init__(self,
simulator,
filename,
pose,
scale=1.0,
is_static=False,
name=None):
"""Initialize."""
Body.__init__(self,
simulator=simulator,
filename=filename,
pose=pose,
scale=scale,
is_static=is_static,
name=name)
self._link_target = LinkTarget(self)
self._joint_target = JointTarget(self)
self._neutral_joint_positions = None
self._max_joint_velocities = [
joint.max_velocity for joint in self.joints
]
self._max_reaction_forces = None
[docs] def set_target_joint_positions(self,
joint_positions,
timeout=TIMEOUT,
threshold=POSITION_THRESHOLD):
"""Set target joint positions for position control.
Args:
joint_positions: The joint positions for each specified joint.
timeout: Seconds to wait for move to finish.
threshold: Joint position threshold in radians across each joint
when move is considered successful.
"""
indices = []
positions = []
if isinstance(joint_positions, (list, tuple)):
for ind, position in enumerate(joint_positions):
if position is not None:
indices.append(ind)
positions.append(position)
elif isinstance(joint_positions, dict):
for key, position in joint_positions.items():
joint = self.get_joint_by_name(key)
indices.append(joint.index)
positions.append(position)
else:
raise ValueError
num_joints = len(joint_positions)
velocities = [0.0] * num_joints
self._joint_target.set(
indices,
positions,
velocities,
timeout=timeout,
position_threshold=threshold)
[docs] def set_target_link_pose(self,
link_ind,
link_pose,
timeout=TIMEOUT,
threshold=POSITION_THRESHOLD):
"""Set the target pose of the link for position control.
Args:
link_ind: The index of the end effector link.
link_pose: The pose of the end effector link.
timeout: Seconds to wait for move to finish.
threshold: Joint position threshold in radians across each joint
when move is considered successful.
"""
self._link_target.set(
index=link_ind,
pose=link_pose,
timeout=timeout,
position_threshold=threshold)
[docs] def set_target_link_poses(self,
link_ind,
link_poses,
timeout=TIMEOUT,
threshold=POSITION_THRESHOLD):
"""Set the target poses of the link for position control.
The list of poses should be reached sequentially.
Args:
link_ind: The index of the end effector link.
link_pose: The pose of the end effector link.
timeout: Seconds to wait for move to finish.
threshold: Joint position threshold in radians across each joint
when move is considered successful.
"""
assert isinstance(link_poses, list)
self._link_target.set(
index=link_ind,
pose=link_poses,
timeout=timeout,
position_threshold=threshold)
self._link_target.pop()
[docs] def set_neutral_joint_positions(self, joint_positions):
"""Set the neutral joint positions.
This is used for computing the IK solution.
Args:
joint_positions: A list of joint positions.
"""
self._neutral_joint_positions = joint_positions
[docs] def set_max_joint_velocities(self, joint_velocities):
"""Set the maximal joint velocities for position control.
Args:
joint_velocities: The maximal joint velocities.
"""
# TODO(kuanfang): This functionality is not supported by pybulelt yet.
if isinstance(joint_velocities, (list, tuple)):
for joint_ind, joint_velocity in enumerate(joint_velocities):
if joint_velocity is not None:
self._max_joint_velocities[joint_ind] = joint_velocity
elif isinstance(joint_velocities, dict):
for key, joint_velocity in joint_velocities.items():
joint = self.get_joint_by_name(key)
joint_ind = joint.index
self._max_joint_velocities[joint_ind] = joint_velocity
else:
raise ValueError
[docs] def set_max_reaction_force(self, joint_ind, force):
"""Set the maximum reaction force for a joint.
"""
self._max_reaction_forces[joint_ind] = force
self.joints[joint_ind].enable_sensor()
[docs] def reset_targets(self):
"""Reset the joint and link targets."""
self._link_target.reset()
self._joint_target.reset()
[docs] def update(self):
"""Update control and disturbances."""
ik_updated = False
if not self._link_target.is_ready():
if self.simulator.num_steps % STEPS_TO_CHECK_DONE == 0:
if self._check_link_target_done():
self._link_target.reset()
if not self._link_target.is_ready():
if (self.simulator.num_steps % STEPS_TO_UPDATE_IK == 0 or
self._joint_target.is_ready()):
self._update_ik()
ik_updated = True
# Check if the IK computation has converged.
if self.check_joints_reached():
self._link_target.pop()
if not self._joint_target.is_ready():
if (self.simulator.num_steps % STEPS_TO_CHECK_DONE == 0
or ik_updated):
if self._check_joint_target_done():
self._joint_target.reset()
if not self._joint_target.is_ready():
self._update_position_control()
def _check_link_target_done(self):
"""Check if the link target has been reached.
Returns:
True if the target has reached, False otherwise.
"""
# Check timeout.
if self._link_target.stop_time is None:
return True
elif self.physics.time() >= self._link_target.stop_time:
return True
# Check queue clear.
if (self._link_target.pose is None and
len(self._link_target.pose_queue) == 0):
return True
return False
def _check_joint_target_done(self):
"""Check if the joint target has been reached.
Returns:
True if the target has reached, False otherwise.
"""
# Check timeout.
if self._joint_target.stop_time is None:
return True
elif self.physics.time() >= self._joint_target.stop_time:
logger.debug('Time out for the position control.')
return True
# Check if target joints have been reached.
if self.check_joints_reached():
return True
# Check if joints are safe.
if self._max_reaction_forces is not None:
if not self.check_joints_safe():
return True
return False
def _update_position_control(self):
"""Update the position control."""
self.physics.position_control_array(
self.uid,
self._joint_target.indices,
target_positions=self._joint_target.positions,
target_velocities=self._joint_target.velocities,
position_gains=self._joint_target.position_gains,
velocity_gains=self._joint_target.velocity_gains)
def _update_ik(self):
"""Update the inverse kinematics results.
"""
num_joints = self._link_target.index
joint_inds = range(num_joints)
# Computer IK.
positions = self.physics.compute_inverse_kinematics(
self._link_target.link.uid,
self._link_target.pose,
neutral_positions=self._neutral_joint_positions)
# TODO: Bullet IK results include irrelevant joints, which can cause
# problems for some URDF models.
positions = positions[:num_joints]
# If there is no more target lin poses waiting in the queue, the target
# velocities are zeros; otherwise velocities do not matter.
if len(self._link_target.pose_queue) == 0:
velocities = [0.0] * num_joints
else:
velocities = None
# Set the position control.
self._joint_target.set(
joint_inds,
positions,
velocities,
start_time=self._link_target.start_time,
stop_time=self._link_target.stop_time,
position_threshold=self._link_target.position_threshold,
velocity_threshold=self._link_target.velocity_threshold)
[docs] def check_joints_reached(self):
"""Check if the specified joint positions are reached.
Returns:
True is all specified joint positions are reached and corresponding
joint velocities are close to zero, False otherwise.
"""
if self._joint_target.is_ready():
return True
inds = self._joint_target.indices
positions = self._joint_target.positions
velocities = self._joint_target.velocities
if velocities is None:
velocities = [None] * len(inds)
for ind, target_position, target_velocity in zip(
inds, positions, velocities):
current_position = self.joints[ind].position
delta_position = target_position - current_position
position_reached = (
abs(delta_position) < self._joint_target.position_threshold)
if target_velocity is None:
velocity_reached = True
else:
current_velocity = self.joint_velocities[ind]
delta_velocity = target_velocity - current_velocity
velocity_reached = (
abs(delta_velocity) < self._joint_target.velocity_threshold
)
if not (position_reached and velocity_reached):
return False
return True
[docs] def check_joints_safe(self):
"""Check if the joint is safe.
Returns:
True for safe, False otherwise.
"""
for joint_ind in self._joint_target.indices:
max_force = self._max_reaction_forces[joint_ind]
if max_force is None:
continue
else:
joint = self.joints[joint_ind]
reaction_force = joint.reaction_force
reaction_force_norm = np.linalg.norm(reaction_force[:3])
is_safe = reaction_force_norm < max_force
if not is_safe:
logger.warning(
'Joint %s has a reaction force %s, '
'which is larger than the threshold %.2f.'
% (joint_ind, reaction_force_norm, max_force))
return False
return True
[docs] def is_ready(self, joint_inds=None):
"""Check if the body is ready.
Args:
joint_inds: The joints to be checked.
Returns:
True if all control commands are done, False otherwise.
"""
if self._check_link_target_done():
self._link_target.reset()
if self._check_joint_target_done():
self._joint_target.reset()
if joint_inds is None:
return (self._link_target.is_ready() and
self._joint_target.is_ready())
else:
if not self._link_target.is_ready():
for joint_ind in joint_inds:
if joint_ind < self._link_target.index:
return False
if not self._joint_target.is_ready():
for joint_ind in joint_inds:
if joint_ind in self._joint_target.indices:
return False
return True


Javascript testing with Rails and QUnit
Testing a Rails backend is considerably easier than that of its ugly frontend javascript brother. When looking for a solution to frontend testing solution, I usually look for the following:
- Easily runnable
- Simple configuration
- CI friendly (TravisCI would be nice)
- Rails asset loading
And some bonuses:
- Multiple browser testing support
- Code coverage reports
Finding all these that played nicely was extremely difficult. Initially, I settled on using the
rails-qunit
gem. This does quite a nice job for a little while. There is a nice generator
included making for an easy setup.
However, I desperately wanted these tests to be part of my Travis build. Especially with the rise of single
page applications (SPA), the javascript quickly became the most important of my app to test. Now let me
introduce you to a wonderful gem called teaspoon
. Teaspoon comes with support with Jasmine, Mocha
and QUnit. It's an amazing little testing library.
def foo
puts 'foo'
end


| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | package org.apache.commons.beanutils; | |
| 18 | ||
| 19 | ||
| 20 | /** | |
| 21 | *
Decorates a {@link DynaBean} to provide Map behaviour.
 | |
| 22 | * | |
| 23 | *
The motivation for this implementation is to provide access to {@link DynaBean} | |
| 24 | * properties in technologies that are unaware of BeanUtils and {@link DynaBean}s - | |
| 25 | * such as the expression languages of JSTL and JSF.
 | |
| 26 | * | |
| 27 | *
This can be achieved either by wrapping the {@link DynaBean} prior to | |
| 28 | * providing it to the technolody to process or by providing a Map | |
| 29 | * accessor method on the DynaBean implementation: | |
| 30 | *
 | |
| 31 | * public Map getMap() { | |
| 32 | * return new DynaBeanMapDecorator(this); | |
| 33 | * }
 | |
| 34 | *
 | |
| 35 | *
 | |
| 36 | * | |
| 37 | *
This, for example, could be used in JSTL in the following way to access | |
| 38 | * a DynaBean's fooProperty: | |
| 39 | *

${myDynaBean.map.fooProperty}

 | |
| 40 | *
 | |
| 41 | * | |
| 42 | *
Usage
 | |
| 43 | * | |
| 44 | *
To decorate a {@link DynaBean} simply instantiate this class with the | |
| 45 | * target {@link DynaBean}:
 | |
| 46 | * | |
| 47 | *

Map fooMap = new DynaBeanMapDecorator(fooDynaBean);

 | |
| 48 | * | |
| 49 | *
The above example creates a read only Map. | |
| 50 | * To create a Map which can be modified, construct a | |
| 51 | * DynaBeanMapDecorator with the read only | |
| 52 | * attribute set to false:
 | |
| 53 | * | |
| 54 | *

Map fooMap = new DynaBeanMapDecorator(fooDynaBean, false);

 | |
| 55 | * | |
| 56 | *
Limitations
 | |
| 57 | *
In this implementation the entrySet(), keySet() | |
| 58 | * and values() methods create an unmodifiable | |
| 59 | * Set and it does not support the Map's clear() | |
| 60 | * and remove() operations.
 | |
| 61 | *
For reasons of backwards compatibility, the generic types of this | |
| 62 | * {@code Map} implementation are {@code <Object, Object>}. However, the | |
| 63 | * keys of the map are typically strings.
 | |
| 64 | * | |
| 65 | * @since BeanUtils 1.8.0 | |
| 66 | * @version $Id$ | |
| 67 | * @deprecated Use {@link DynaBeanPropertyMapDecorator} instead. When adding | |
| 68 | * generics it turned out that it was not possible to use the correct type | |
| 69 | * parameters without breaking backwards compatibility. Therefore, class | |
| 70 | * {@code DynaBeanPropertyMapDecorator} was introduced as a replacement. | |
| 71 | */ | |
| 72 | @Deprecated | |
| 73 | public class DynaBeanMapDecorator extends BaseDynaBeanMapDecorator<Object> { | |
| 74 | /** | |
| 75 | * Construct a Map for the specified {@link DynaBean}. | |
| 76 | * | |
| 77 | * @param dynaBean The dyna bean being decorated | |
| 78 | * @param readOnly true if the Map is read only | |
| 79 | * otherwise false | |
| 80 | * @throws IllegalArgumentException if the {@link DynaBean} is null. | |
| 81 | */ | |
| 82 | public DynaBeanMapDecorator(final DynaBean dynaBean, final boolean readOnly) { | |
| 83 | super(dynaBean, readOnly); | |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * Constructs a read only Map for the specified | |
| 88 | * {@link DynaBean}. | |
| 89 | * | |
| 90 | * @param dynaBean The dyna bean being decorated | |
| 91 | * @throws IllegalArgumentException if the {@link DynaBean} is null. | |
| 92 | */ | |
| 93 | public DynaBeanMapDecorator(final DynaBean dynaBean) { | |
| 94 | super(dynaBean); | |
| 95 | } | |
| 96 | ||
| 97 | @Override | |
| 98 | protected Object convertKey(final String propertyName) { | |
| 99 |
2
1. convertKey : replaced return value with null for org/apache/commons/beanutils/DynaBeanMapDecorator::convertKey → KILLED 2. convertKey : mutated return of Object value for org/apache/commons/beanutils/DynaBeanMapDecorator::convertKey to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return propertyName; |
| 100 | } | |
| 101 | } | |
Mutations | ||
| 99 |
1.1 2.2 |


The constantly evolving cloud Technologies and their amazing underlying new architectures are my latest passion. I grow it by working as lead engineer in the Advance Parallel Computing Lab at Atos and pushing on my side project IoBirds: an IoT platform for industry.
I consider myself an enthusiastic of Computer Science, building applications for over ten years. The wide range of projects in which I have taken part during this time have led me to know many different develop environments, requirements and technologies. Therefore, I can say nowadays that I am a professional with a high ability to adapt to new challenges.
Besides computer science, I also enjoy exploring and trying out new things, like playing chess, climbing, or more recently learning to draw.
Luckily, some of the work I do leaves a digital trail. Please feel free to check my activity at GitHub, StackOverflow, LinkedIn or Twitter.
Developing orchestration mechanisms for native HPC applications, to automate its lifecycle in both HPC and Cloud environments.
Responsible of the products and technologies the company develops.
Research and development of compression techniques to be applied on massive bone “alografts”, prosthesis and synthetic implant virtual models, as well as surgical planning.
I combined my work as a researcher with teaching computer architecture,C classes and artificial ingelligence..
I was researching and designing different hardware algorithms to do topological processing and analysis of images on FPGAs using the membrane computing paradigm, at the Computational Applied Topology and Applied Mathematics research group.
During my studies I obtained three grants to work within a development team at the University of Seville, where I took part on the design and implementation of three projects requested by different companies. In this period of time I could put in practice all that I was learning in my degree, working as a team.


001/* 002 * Copyright 2017-present Teamwork.com 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.teamwork.autocomplete; 018 019import android.widget.Filter; 020import android.widget.ListAdapter; 021import android.widget.MultiAutoCompleteTextView; 022 023import androidx.annotation.NonNull; 024import androidx.annotation.Nullable; 025 026import com.teamwork.autocomplete.adapter.AutoCompleteTypeAdapter; 027import com.teamwork.autocomplete.adapter.TypeAdapterDelegate; 028import com.teamwork.autocomplete.filter.BaseTokenFilter; 029import com.teamwork.autocomplete.filter.HandleTokenFilter; 030import com.teamwork.autocomplete.filter.SimpleTokenFilter; 031import com.teamwork.autocomplete.filter.TokenFilter; 032import com.teamwork.autocomplete.model.SimpleItem; 033import com.teamwork.autocomplete.tokenizer.PrefixTokenizer; 034import com.teamwork.autocomplete.view.AutoCompleteViewBinder; 035import com.teamwork.autocomplete.view.MultiAutoCompleteEditText; 036import com.teamwork.autocomplete.view.SimpleItemViewBinder; 037 038import java.util.ArrayList; 039import java.util.List; 040 041/** 042 * The main MultiAutoComplete component, it manages the type adapters and holds a reference to the managed {@link 043 * MultiAutoCompleteTextView}. It also provides lifecycle methods to attach/detach the view itself. 044 *
 045 * The managed {@link MultiAutoCompleteTextView} can be styled and used as normal. 046 * Once configured, the library will take care of calling {@link MultiAutoCompleteTextView#setTokenizer(MultiAutoCompleteTextView.Tokenizer)} 047 * and {@link MultiAutoCompleteTextView#setAdapter(ListAdapter)} and present the data for you when there is a token match. 048 *
 049 * It holds an "adapter of adapters" internally, with which the component can handle multiple data types in the same instance and decide 050 * which adapter to use for filtering depending on what kind of token is being typed in. 051 *
 052 * To create an instance use one of the static factory methods in {@link MultiAutoComplete.Build} or, for full customization, use the 053 * {@link Builder} itself. 054 * 055 * @author Marco Salis 056 */ 057public interface MultiAutoComplete { 058 059 /** 060 * Call this when the view gets attached to the component using {@link MultiAutoComplete}. This is usually done in 061 * Activity.onCreate(Bundle) or Fragment.onViewCreated(View, Bundle). 062 * 063 * @param view The {@link MultiAutoCompleteEditText} view that this {@link MultiAutoComplete} will be managing. 064 */ 065 void onViewAttached(@NonNull MultiAutoCompleteEditText view); 066 067 /** 068 * Call this when the view gets detached to the component using {@link MultiAutoComplete}, to avoid memory leaks or usage of a view that 069 * is no longer on screen. This is usually done in Activity.onDestroy() or Fragment.onDestroyView(). 070 */ 071 void onViewDetached(); 072 073 074 /** 075 * {@link MultiAutoComplete} concrete implementation builder component. 076 */ 077 class Builder { 078 079 private final List<TypeAdapterDelegate<?>> typeAdapters = new ArrayList<>(); 080 081 private MultiAutoCompleteTextView.Tokenizer tokenizer; 082 private @Nullable 083 Delayer delayer; 084 085 /** 086 * Set the {@link MultiAutoCompleteTextView.Tokenizer} for the {@link MultiAutoComplete} being built. 087 * 088 * @param tokenizer The tokenizer. 089 * @return The builder for chaining calls. 090 * @see MultiAutoCompleteTextView.Tokenizer 091 */ 092 public Builder tokenizer(@NonNull MultiAutoCompleteTextView.Tokenizer tokenizer) { 093 this.tokenizer = tokenizer; 094 return this; 095 } 096 097 /** 098 * Set the {@link Delayer} to be used to delay filtering on this {@link MultiAutoComplete}. 099 * 100 * @param delayer The delayer to use. 101 * @return The builder for chaining calls. 102 * @see Delayer 103 * @see android.widget.Filter 104 */ 105 public Builder delayer(@NonNull Delayer delayer) { 106 this.delayer = delayer; 107 return this; 108 } 109 110 /** 111 * Add a {@link AutoCompleteTypeAdapter} to the {@link MultiAutoComplete} being built. 112 * The type adapter must be built with one of the {@link AutoCompleteTypeAdapter.Build} factory methods. 113 *
 114 * Note: the insertion order will determine which type adapter will handle a specific token. 115 * If there are multiple adapters that support a specific token format, only the first matching will be used. 116 * 117 * @param typeAdapter The type adapter to add. 118 * @return The builder for chaining calls. 119 */ 120 public Builder addTypeAdapter(@NonNull AutoCompleteTypeAdapter<?> typeAdapter) { 121 if (!(typeAdapter instanceof TypeAdapterDelegate)) { 122 throw new IllegalArgumentException("Type adapter must implement TypeAdapterDelegate!"); 123 } 124 typeAdapters.add((TypeAdapterDelegate<?>) typeAdapter); 125 return this; 126 } 127 128 /** 129 * Build the configured instance of this {@link MultiAutoComplete}. 130 */ 131 public @NonNull MultiAutoComplete build() { 132 return new MultiAutoCompleteImpl(tokenizer, typeAdapters, delayer); 133 } 134 } 135 136 137 /** 138 * Static factory helper methods to construct an instance of {@link MultiAutoComplete} with default parameters. 139 *
 140 * The {@link TokenFilter} implementations set by this methods will match the current constraint with the value returned by the {@link 141 * #toString()} method of the passed items. 142 * 143 * @see BaseTokenFilter 144 */ 145 class Build { 146 147 /** 148 * Build an instance of {@link MultiAutoComplete} from the passed list of {@link SimpleItem}s with the default UI. 149 * The auto complete will be triggered at every space-prefixed character, on each comma-separated value. 150 *
 151 * Use this method to implement if no handle, customization of the layout, data type or filtering is required. 152 * 153 * @param items The List of items to display (only the text will be shown). 154 * @return The built {@link MultiAutoComplete} instance. 155 * @see SimpleItem 156 * @see SimpleItemViewBinder 157 * @see SimpleTokenFilter 158 */ 159 @NonNull 160 public static MultiAutoComplete from(@NonNull List<SimpleItem> items) { 161 AutoCompleteTypeAdapter<SimpleItem> typeAdapter = 162 AutoCompleteTypeAdapter.Build.from(new SimpleItemViewBinder(), new SimpleTokenFilter<>()); 163 typeAdapter.setItems(items); 164 return new Builder() 165 .tokenizer(new MultiAutoCompleteTextView.CommaTokenizer()) 166 .addTypeAdapter(typeAdapter) 167 .build(); 168 } 169 170 /** 171 * Build an instance of {@link MultiAutoComplete} from the passed list of {@link SimpleItem}s with the default UI. 172 * The auto complete will be triggered by the passed char handle. 173 *
 174 * Use this method to implement if no customization of the layout, data type or filtering is required. 175 * 176 * @param handle The character handle that will trigger the auto complete drop down. 177 * @param items The List of items to display (only the text will be shown). 178 * @return The built {@link MultiAutoComplete} instance. 179 * @see SimpleItem 180 * @see SimpleItemViewBinder 181 */ 182 @NonNull 183 public static MultiAutoComplete from(char handle, @NonNull List<SimpleItem> items) { 184 return from(handle, new SimpleItemViewBinder(), items); 185 } 186 187 /** 188 * Build an instance of {@link MultiAutoComplete} from the passed list of item models and a layout provided by a custom view binder. 189 * The auto complete will be triggered by the passed char handle. 190 *
 191 * Use this method to implement if no customization of the filtering and tokenizer is required. 192 * 193 * @param handle The character handle that will trigger the auto complete drop down. 194 * @param viewBinder An {@link AutoCompleteViewBinder} to provide a custom layout and data binding. 195 * @param items The List of items to use as data set. 196 * @return The built {@link MultiAutoComplete} instance. 197 */ 198 @NonNull 199 public static <M> MultiAutoComplete from(char handle, @NonNull AutoCompleteViewBinder<M> viewBinder, @NonNull List<M> items) { 200 AutoCompleteTypeAdapter<M> typeAdapter = 201 AutoCompleteTypeAdapter.Build.from(viewBinder, new HandleTokenFilter<>(handle)); 202 typeAdapter.setItems(items); 203 return new Builder() 204 .tokenizer(new PrefixTokenizer(handle)) 205 .addTypeAdapter(typeAdapter) 206 .build(); 207 } 208 } 209 210 211 /** 212 * Delegate interface for the hidden {@link Filter}$Delayer interface, used to delay the filtering of the text constraint on the 213 * {@link MultiAutoCompleteTextView}. 214 *
 215 * Important note: {@link MultiAutoComplete} uses reflection internally to access the state of the Android {@link Filter} and 216 * set the hidden delayer. Its behaviour is not guaranteed for future Android versions, and it will fail silently in some scenarios (an 217 * error message is logged into the LogCat console when that happens). 218 *
 219 * Implementations must be thread safe. 220 */ 221 interface Delayer { 222 223 /** 224 * Get the delay with which the filtering will be performed after the constraint change from the user. 225 * 226 * @param constraint The constraint passed to {@link Filter#filter(CharSequence)}. 227 * @return The delay with which the filtering operation on the {@link MultiAutoCompleteEditText} will occur in milliseconds. 228 */ 229 long getPostingDelay(CharSequence constraint); 230 } 231 232}


public static class PaymentIntentParameters.Builder
The PaymentIntentParameters.Builder
class provides a convenient way to create a new
class PaymentIntentParameters
instance without having to deal with parameters that aren't
relevant to your integration.
class PaymentIntentParameters
| Constructor and Description |
|---|
Builder()
The
PaymentIntentParameters.Builder class provides a convenient way to create a new
class PaymentIntentParameters instance without having to deal with parameters that aren't
relevant to your integration. |
| Modifier and Type | Method and Description |
|---|---|
PaymentIntentParameters |
build()
Create a final instance of
class PaymentIntentParameters with the parameters that
you've set. |
PaymentIntentParameters.Builder |
setAmount(int amount)
Set the amount of the payment, provided in the currency's smallest unit.
|
PaymentIntentParameters.Builder |
setApplicationFeeAmount(int amount)
Set the amount of the application fee (if any) that will be applied to the
payment and transferred to the application owner’s Stripe account. To use an
application fee, the request must be made on behalf of another account,
using the
stripeAccount property or an OAuth key. |
PaymentIntentParameters.Builder |
setCurrency(java.lang.String currency)
Set the three-letter ISO currency code, in lowercase. Must be a supported currency.
|
PaymentIntentParameters.Builder |
setCustomer(java.lang.String customer)
Set the ID of the Customer this
class PaymentIntent is for, if one exists. |
PaymentIntentParameters.Builder |
setDescription(java.lang.String description)
Set the description - an arbitrary string attached to the object. If you send a receipt
email for this payment, the email will include the description.
|
PaymentIntentParameters.Builder |
setMetadata(java.util.Map<java.lang.String,java.lang.String> metadata)
Set the map of key-value pairs that you can attach to an object. This can be useful for
storing additional information about the object in a structured format.
|
PaymentIntentParameters.Builder |
setOnBehalfOf(java.lang.String onBehalfOf)
Set the Stripe account ID for which these funds are intended.
|
PaymentIntentParameters.Builder |
setReceiptEmail(java.lang.String receiptEmail)
Set the email address that the receipt for the resulting payment will be sent to.
|
PaymentIntentParameters.Builder |
setStatementDescriptor(java.lang.String statementDescriptor)
Set a string to be displayed on your customer's credit card statement. This may be
up to 22 characters. The statement descriptor must contain at least one letter,
may not include <>"' characters, and will appear on your customer's statement
in capital letters. Non-ASCII characters are automatically stripped. While
most banks and card issuers display this information consistently, some may
display it incorrectly or not at all.
|
PaymentIntentParameters.Builder |
setTransferDataDestination(java.lang.String transferDataDestination)
Set the account (if any) the payment will be attributed to for tax reporting, and
where funds from the payment will be transferred to upon payment success.
|
PaymentIntentParameters.Builder |
setTransferGroup(java.lang.String transferGroup)
Set a string that identifies the resulting payment as part of a group.
|
public Builder()
The PaymentIntentParameters.Builder
class provides a convenient way to create a new
class PaymentIntentParameters
instance without having to deal with parameters that aren't
relevant to your integration.
class PaymentIntentParameters
@NotNull public PaymentIntentParameters.Builder setAmount(int amount)
Set the amount of the payment, provided in the currency's smallest unit.
@NotNull public PaymentIntentParameters.Builder setApplicationFeeAmount(int amount)
Set the amount of the application fee (if any) that will be applied to the
payment and transferred to the application owner’s Stripe account. To use an
application fee, the request must be made on behalf of another account,
using the stripeAccount
property or an OAuth key.
The amount must be provided as an int in the currency's smallest unit.
@NotNull public PaymentIntentParameters.Builder setCurrency(@NotNull java.lang.String currency)
Set the three-letter ISO currency code, in lowercase. Must be a supported currency.
@NotNull public PaymentIntentParameters.Builder setCustomer(@NotNull java.lang.String customer)
Set the ID of the Customer this class PaymentIntent
is for, if one exists.
class PaymentIntent
@NotNull public PaymentIntentParameters.Builder setDescription(@NotNull java.lang.String description)
Set the description - an arbitrary string attached to the object. If you send a receipt email for this payment, the email will include the description.
@NotNull public PaymentIntentParameters.Builder setMetadata(@NotNull java.util.Map<java.lang.String,java.lang.String> metadata)
Set the map of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
@NotNull public PaymentIntentParameters.Builder setOnBehalfOf(@NotNull java.lang.String onBehalfOf)
Set the Stripe account ID for which these funds are intended.
When transferDataDestination
is specified, onBehalfOf
must also be
specified and must match the destination of the transfer.
@NotNull public PaymentIntentParameters.Builder setReceiptEmail(@NotNull java.lang.String receiptEmail)
Set the email address that the receipt for the resulting payment will be sent to.
@NotNull public PaymentIntentParameters.Builder setStatementDescriptor(@NotNull java.lang.String statementDescriptor)
Set a string to be displayed on your customer's credit card statement. This may be up to 22 characters. The statement descriptor must contain at least one letter, may not include <>"' characters, and will appear on your customer's statement in capital letters. Non-ASCII characters are automatically stripped. While most banks and card issuers display this information consistently, some may display it incorrectly or not at all.
@NotNull public PaymentIntentParameters.Builder setTransferDataDestination(@NotNull java.lang.String transferDataDestination)
Set the account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to upon payment success.
At capture time, use transfer_dataamount to specify the amount that will be transferred automatically when a charge succeeds.
@NotNull public PaymentIntentParameters.Builder setTransferGroup(@NotNull java.lang.String transferGroup)
Set a string that identifies the resulting payment as part of a group.
@NotNull public PaymentIntentParameters build()
Create a final instance of class PaymentIntentParameters
with the parameters that
you've set.
class PaymentIntentParameters
class PaymentIntentParameters