我有一些适用于接口的类:
这是界面:
public interface Orderable
{
int getOrder()
void setOrder()
}
Run Code Online (Sandbox Code Playgroud)
这是工人阶级:
public class Worker
{
private List<Orderable> workingList;
public void setList(List<Orderable> value) {this.workingList=value;}
public void changePlaces(Orderable o1,Orderable o2)
{
// implementation that make o1.order=o2.order and vice versa
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个实现接口的对象:
public class Cat implements Orderable
{
private int order;
public int getOrder()
{
return this.order;
}
public void setOrder(int value)
{
this.order=value;
}
public Cat(String name,int order)
{
this.name=name;
this.order=order;
}
}
Run Code Online (Sandbox Code Playgroud)
在主要程序中,我创建了一个猫列表.我使用glazed列表在列表更改时以及使用此列表创建控件模型时动态更新控件.
目标是将此列表传输到工作对象,因此我可以在主过程中向列表中添加一些新的cat,并且工作人员将在不再设置其list属性的情况下知道它(list是main proc中的相同对象工人).但是当我把worker.setList(cats)它叫做关于期待可订购的警报时,却得到一只猫......但是Cat实现了Orderable.我该如何解决这个问题? …
这是父类Enterprise.它有雇主,其中一个是企业总裁.
@Entity
class Enterprise
{
// fields
@OneToMany
public List<Employee> getEmployers()
// implementation
@OneToOne
public Employee getPresident()
// implementation
}
Run Code Online (Sandbox Code Playgroud)
这是子Employee类.它只有关于他工作的企业的信息.但问题是我应该使用哪种关联?
@Entity
class Employee
{
// fields
// what association should I use?
public Enterprise getEnterprise()
// implementation
}
Run Code Online (Sandbox Code Playgroud) 例如,我有一组几何图形:
Set<Figure> figures;
Run Code Online (Sandbox Code Playgroud)
图有两种类型:Square和Circle.
我想使用google集合获取一组正方形:
Iterables.filter(figures,squarePredicate);
Run Code Online (Sandbox Code Playgroud)
但是filter方法返回Iterable ...如何从Iterable创建Set?(不使用Iterable循环)
我使用Places库自动完成地址输入.搜索仅限于一个城市,我得到如下输出:
"Rossiya,Moskva,Leninskiy prospekt 28"
如何隐藏"Rossiya,Moskva"?...
我的查询:
function() {
// Search bounds
var p1 = new google.maps.LatLng(54.686534, 35.463867);
var p2 = new google.maps.LatLng(56.926993, 39.506836);
self.options = {
bounds : new google.maps.LatLngBounds(p1, p2),
componentRestrictions: {country: 'ru'},
};
var elements = document.querySelectorAll('.address');
for ( var i = 0; i < elements.length; i++) {
var autocomplete = new google.maps.places.Autocomplete(elements[i],
self.options);
}
Run Code Online (Sandbox Code Playgroud) 实体是Tile,它在地图上用它的坐标唯一标识:
import org.springframework.data.domain.Persistable;
@Entity
class Tile implements Persistable<Tile.Coordinates> {
@Embeddable
public static class Coordinates implements Serializable {
long x;
long y;
public Coordinates(x,y){this.x=x; this.y=y;}
}
@EmbeddedId Coordinates coordinates;
private Tile(){}
public Tile(long x,long y) {this.coordinates=new Coordinates(x,y);}
@Override
public boolean isNew(){
// what is preferred implementation?
}
// other code
}
Run Code Online (Sandbox Code Playgroud)
平铺坐标是预定义的,因为没有坐标的平铺是无意义的.
Tile tile=new Tile(x,y);
Run Code Online (Sandbox Code Playgroud) 我想验证表格单元格中的用户输入,并且我使用 Nimbus 外观和感觉。以下是验证整数输入的单元格编辑器的代码:WholeNumberField
它扩展JTextField并添加了输入验证。
当我为列设置它时,它工作正常,但无法容纳文本:

当我使用默认单元格编辑器时,一切看起来都很好:

这个编辑器如何看起来像默认编辑器?
java ×4
casting ×1
collections ×1
glazedlists ×1
guava ×1
hibernate ×1
interface ×1
jpa ×1
jtable ×1
spring-data ×1
swing ×1